From a1cd767e27bacc7829c3bdb2a5bf64b60c8e8506 Mon Sep 17 00:00:00 2001 From: Cameron Thornton Date: Fri, 27 Mar 2020 15:54:41 -0700 Subject: [PATCH] Do not return most sweeper errors (#3315) * Do not return sql database instance sweeper errors * Fix some other sweepers * Fix typo --- ...cess_context_manager_access_policy_test.go.erb | 9 ++++++--- .../resource_cloudfunctions_function_test.go.erb | 6 ++++-- .../resource_sql_database_instance_test.go.erb | 15 ++++++++++----- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/third_party/terraform/tests/resource_access_context_manager_access_policy_test.go.erb b/third_party/terraform/tests/resource_access_context_manager_access_policy_test.go.erb index 1353e5e4bc01..263010e7a641 100644 --- a/third_party/terraform/tests/resource_access_context_manager_access_policy_test.go.erb +++ b/third_party/terraform/tests/resource_access_context_manager_access_policy_test.go.erb @@ -43,7 +43,8 @@ func testSweepAccessContextManagerPolicies(region string) error { resp, err := sendRequest(config, "GET", "", listUrl, nil) if err != nil && !isGoogleApiErrorWithCode(err, 404) { - return fmt.Errorf("unable to list AccessPolicies for organization %q: %v", testOrg, err) + log.Printf("unable to list AccessPolicies for organization %q: %v", testOrg, err) + return nil } var policies []interface{} if resp != nil { @@ -57,7 +58,8 @@ func testSweepAccessContextManagerPolicies(region string) error { return nil } if len(policies) > 1 { - return fmt.Errorf("unexpected - more than one access policies found, change the tests") + log.Printf("unexpected - more than one access policies found, change the tests") + return nil } policy := policies[0].(map[string]interface{}) @@ -65,7 +67,8 @@ func testSweepAccessContextManagerPolicies(region string) error { policyUrl := config.AccessContextManagerBasePath + policy["name"].(string) if _, err := sendRequest(config, "DELETE", "", policyUrl, nil); err != nil && !isGoogleApiErrorWithCode(err, 404) { - return fmt.Errorf("unable to delete access policy %q", policy["name"].(string)) + log.Printf("unable to delete access policy %q", policy["name"].(string)) + return nil } return nil diff --git a/third_party/terraform/tests/resource_cloudfunctions_function_test.go.erb b/third_party/terraform/tests/resource_cloudfunctions_function_test.go.erb index 86b07e15426a..6ccfb03ab10b 100644 --- a/third_party/terraform/tests/resource_cloudfunctions_function_test.go.erb +++ b/third_party/terraform/tests/resource_cloudfunctions_function_test.go.erb @@ -512,7 +512,8 @@ func createZIPArchiveForCloudFunctionSource(t *testing.T, sourcePath string) str func sweepCloudFunctionSourceZipArchives(_ string) error { files, err := ioutil.ReadDir(os.TempDir()) if err != nil { - return err + log.Printf("Error reading files: %s",err) + return nil } for _, f := range files { if f.IsDir() { @@ -521,7 +522,8 @@ func sweepCloudFunctionSourceZipArchives(_ string) error { if strings.HasPrefix(f.Name(), testFunctionsSourceArchivePrefix) { filepath := fmt.Sprintf("%s/%s", os.TempDir(), f.Name()) if err := os.Remove(filepath); err != nil { - return err + log.Printf("Error removing files: %s",err) + return nil } log.Printf("[INFO] cloud functions sweeper removed old file %s", filepath) } diff --git a/third_party/terraform/tests/resource_sql_database_instance_test.go.erb b/third_party/terraform/tests/resource_sql_database_instance_test.go.erb index 7cc0992b0aae..6b1fcd0d95fa 100644 --- a/third_party/terraform/tests/resource_sql_database_instance_test.go.erb +++ b/third_party/terraform/tests/resource_sql_database_instance_test.go.erb @@ -49,7 +49,8 @@ func testSweepDatabases(region string) error { found, err := config.clientSqlAdmin.Instances.List(config.Project).Do() if err != nil { - log.Fatalf("error listing databases: %s", err) + log.Printf("error listing databases: %s", err) + return nil } if len(found.Items) == 0 { @@ -100,7 +101,8 @@ func testSweepDatabases(region string) error { op, err := config.clientSqlAdmin.Instances.StopReplica(config.Project, replicaName).Do() if err != nil { - return fmt.Errorf("error, failed to stop replica instance (%s) for instance (%s): %s", replicaName, d.Name, err) + log.Printf("error, failed to stop replica instance (%s) for instance (%s): %s", replicaName, d.Name, err) + return nil } err = sqlAdminOperationWait(config, op, config.Project, "Stop Replica") @@ -108,7 +110,8 @@ func testSweepDatabases(region string) error { if strings.Contains(err.Error(), "does not exist") { log.Printf("Replication operation not found") } else { - return err + log.Printf("Error waiting for sqlAdmin operation: %s", err) + return nil } } @@ -130,7 +133,8 @@ func testSweepDatabases(region string) error { continue } - return fmt.Errorf("Error, failed to delete instance %s: %s", db, err) + log.Printf("Error, failed to delete instance %s: %s", db, err) + return nil } err = sqlAdminOperationWait(config, op, config.Project, "Delete Instance") @@ -139,7 +143,8 @@ func testSweepDatabases(region string) error { log.Printf("SQL instance not found") continue } - return err + log.Printf("Error, failed to delete instance %s: %s", db, err) + return nil } } }