Skip to content

Commit f923ff2

Browse files
Do not return most sweeper errors (#3315) (#1909)
* Do not return sql database instance sweeper errors * Fix some other sweepers * Fix typo Signed-off-by: Modular Magician <[email protected]>
1 parent 7c1138e commit f923ff2

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

.changelog/3315.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

google-beta/resource_access_context_manager_access_policy_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ func testSweepAccessContextManagerPolicies(region string) error {
4242

4343
resp, err := sendRequest(config, "GET", "", listUrl, nil)
4444
if err != nil && !isGoogleApiErrorWithCode(err, 404) {
45-
return fmt.Errorf("unable to list AccessPolicies for organization %q: %v", testOrg, err)
45+
log.Printf("unable to list AccessPolicies for organization %q: %v", testOrg, err)
46+
return nil
4647
}
4748
var policies []interface{}
4849
if resp != nil {
@@ -56,15 +57,17 @@ func testSweepAccessContextManagerPolicies(region string) error {
5657
return nil
5758
}
5859
if len(policies) > 1 {
59-
return fmt.Errorf("unexpected - more than one access policies found, change the tests")
60+
log.Printf("unexpected - more than one access policies found, change the tests")
61+
return nil
6062
}
6163

6264
policy := policies[0].(map[string]interface{})
6365
log.Printf("[DEBUG] Deleting test Access Policies %q", policy["name"])
6466

6567
policyUrl := config.AccessContextManagerBasePath + policy["name"].(string)
6668
if _, err := sendRequest(config, "DELETE", "", policyUrl, nil); err != nil && !isGoogleApiErrorWithCode(err, 404) {
67-
return fmt.Errorf("unable to delete access policy %q", policy["name"].(string))
69+
log.Printf("unable to delete access policy %q", policy["name"].(string))
70+
return nil
6871
}
6972

7073
return nil

google-beta/resource_cloudfunctions_function_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,8 @@ func createZIPArchiveForCloudFunctionSource(t *testing.T, sourcePath string) str
513513
func sweepCloudFunctionSourceZipArchives(_ string) error {
514514
files, err := ioutil.ReadDir(os.TempDir())
515515
if err != nil {
516-
return err
516+
log.Printf("Error reading files: %s", err)
517+
return nil
517518
}
518519
for _, f := range files {
519520
if f.IsDir() {
@@ -522,7 +523,8 @@ func sweepCloudFunctionSourceZipArchives(_ string) error {
522523
if strings.HasPrefix(f.Name(), testFunctionsSourceArchivePrefix) {
523524
filepath := fmt.Sprintf("%s/%s", os.TempDir(), f.Name())
524525
if err := os.Remove(filepath); err != nil {
525-
return err
526+
log.Printf("Error removing files: %s", err)
527+
return nil
526528
}
527529
log.Printf("[INFO] cloud functions sweeper removed old file %s", filepath)
528530
}

google-beta/resource_sql_database_instance_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ func testSweepDatabases(region string) error {
4848

4949
found, err := config.clientSqlAdmin.Instances.List(config.Project).Do()
5050
if err != nil {
51-
log.Fatalf("error listing databases: %s", err)
51+
log.Printf("error listing databases: %s", err)
52+
return nil
5253
}
5354

5455
if len(found.Items) == 0 {
@@ -99,15 +100,17 @@ func testSweepDatabases(region string) error {
99100
op, err := config.clientSqlAdmin.Instances.StopReplica(config.Project, replicaName).Do()
100101

101102
if err != nil {
102-
return fmt.Errorf("error, failed to stop replica instance (%s) for instance (%s): %s", replicaName, d.Name, err)
103+
log.Printf("error, failed to stop replica instance (%s) for instance (%s): %s", replicaName, d.Name, err)
104+
return nil
103105
}
104106

105107
err = sqlAdminOperationWait(config, op, config.Project, "Stop Replica")
106108
if err != nil {
107109
if strings.Contains(err.Error(), "does not exist") {
108110
log.Printf("Replication operation not found")
109111
} else {
110-
return err
112+
log.Printf("Error waiting for sqlAdmin operation: %s", err)
113+
return nil
111114
}
112115
}
113116

@@ -129,7 +132,8 @@ func testSweepDatabases(region string) error {
129132
continue
130133
}
131134

132-
return fmt.Errorf("Error, failed to delete instance %s: %s", db, err)
135+
log.Printf("Error, failed to delete instance %s: %s", db, err)
136+
return nil
133137
}
134138

135139
err = sqlAdminOperationWait(config, op, config.Project, "Delete Instance")
@@ -138,7 +142,8 @@ func testSweepDatabases(region string) error {
138142
log.Printf("SQL instance not found")
139143
continue
140144
}
141-
return err
145+
log.Printf("Error, failed to delete instance %s: %s", db, err)
146+
return nil
142147
}
143148
}
144149
}

0 commit comments

Comments
 (0)