Skip to content

Commit 14e7ce1

Browse files
authored
fix(project_cleanup): check all cluster locations and defer when deleting (#248)
1 parent 4287d62 commit 14e7ce1

File tree

1 file changed

+2
-1
lines changed
  • modules/project_cleanup/function_source

1 file changed

+2
-1
lines changed

‎modules/project_cleanup/function_source/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ func invoke(ctx context.Context) {
626626

627627
removeProjectClusters := func(projectId string) int {
628628
logger.Printf("Try to remove clusters for [%s]", projectId)
629-
reqLCR := &containerpb.ListClustersRequest{Parent: fmt.Sprintf("projects/%s/locations/*", projectId)}
629+
reqLCR := &containerpb.ListClustersRequest{Parent: fmt.Sprintf("projects/%s/locations/-", projectId)}
630630
listResponse, err := containerService.ListClusters(ctx, reqLCR)
631631
if err != nil {
632632
logger.Printf("Failed to list clusters for [%s], error [%s]", projectId, err.Error())
@@ -695,6 +695,7 @@ func invoke(ctx context.Context) {
695695
logger.Printf("Try to remove project [%s]", projectId)
696696
if clusters := removeProjectClusters(projectId); clusters != 0 {
697697
logger.Printf("Defer removing project [%s], %d clusters marked for deletion", projectId, clusters)
698+
return
698699
}
699700
err := removeProjectById(projectId)
700701
if err != nil {

0 commit comments

Comments
 (0)