From bb84b480e69d7e51e28179f00ecf4f4435eeb3fe Mon Sep 17 00:00:00 2001 From: Andrew Peabody Date: Fri, 26 Jul 2024 22:54:50 +0000 Subject: [PATCH] fix(project_cleanup): check all cluster locations and defer --- modules/project_cleanup/function_source/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/project_cleanup/function_source/main.go b/modules/project_cleanup/function_source/main.go index c77102a6..67738f8b 100644 --- a/modules/project_cleanup/function_source/main.go +++ b/modules/project_cleanup/function_source/main.go @@ -626,7 +626,7 @@ func invoke(ctx context.Context) { removeProjectClusters := func(projectId string) int { logger.Printf("Try to remove clusters for [%s]", projectId) - reqLCR := &containerpb.ListClustersRequest{Parent: fmt.Sprintf("projects/%s/locations/*", projectId)} + reqLCR := &containerpb.ListClustersRequest{Parent: fmt.Sprintf("projects/%s/locations/-", projectId)} listResponse, err := containerService.ListClusters(ctx, reqLCR) if err != nil { logger.Printf("Failed to list clusters for [%s], error [%s]", projectId, err.Error()) @@ -695,6 +695,7 @@ func invoke(ctx context.Context) { logger.Printf("Try to remove project [%s]", projectId) if clusters := removeProjectClusters(projectId); clusters != 0 { logger.Printf("Defer removing project [%s], %d clusters marked for deletion", projectId, clusters) + return } err := removeProjectById(projectId) if err != nil {