Skip to content

Commit 95730fd

Browse files
Merge pull request #8489 from barbacbd/OCPBUGS-33681
OCPBUGS-33681: Cleanup bootstrap resources for capg install
2 parents dfb88b9 + 8e9a486 commit 95730fd

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

pkg/asset/ignition/bootstrap/gcp/storage.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ func DestroyStorage(ctx context.Context, clusterID string) error {
131131
}
132132
bucketName := GetBootstrapStorageName(clusterID)
133133

134+
if err := client.Bucket(bucketName).Object(bootstrapIgnitionBucketObjName).Delete(ctx); err != nil {
135+
return fmt.Errorf("failed to delete bucket object %s: %w", bootstrapIgnitionBucketObjName, err)
136+
}
137+
134138
// Deleting a bucket will delete the managed folders and bucket objects.
135139
if err := client.Bucket(bucketName).Delete(ctx); err != nil {
136140
return fmt.Errorf("failed to delete bucket %s: %w", bucketName, err)

pkg/infrastructure/gcp/clusterapi/clusterapi.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
capg "sigs.k8s.io/cluster-api-provider-gcp/api/v1beta1"
1313
"sigs.k8s.io/controller-runtime/pkg/client"
1414

15-
"github.com/openshift/installer/pkg/asset/cluster/metadata"
1615
"github.com/openshift/installer/pkg/asset/cluster/tfvars"
1716
"github.com/openshift/installer/pkg/asset/ignition/bootstrap/gcp"
1817
icgcp "github.com/openshift/installer/pkg/asset/installconfig/gcp"
@@ -31,6 +30,7 @@ var _ clusterapi.PreProvider = (*Provider)(nil)
3130
var _ clusterapi.IgnitionProvider = (*Provider)(nil)
3231
var _ clusterapi.InfraReadyProvider = (*Provider)(nil)
3332
var _ clusterapi.PostProvider = (*Provider)(nil)
33+
var _ clusterapi.BootstrapDestroyer = (*Provider)(nil)
3434

3535
// Name returns the name for the platform.
3636
func (p Provider) Name() string {
@@ -224,14 +224,10 @@ func (p Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput)
224224
}
225225

226226
// DestroyBootstrap destroys the temporary bootstrap resources.
227-
func (p Provider) DestroyBootstrap(dir string) error {
227+
func (p Provider) DestroyBootstrap(ctx context.Context, in clusterapi.BootstrapDestroyInput) error {
228228
logrus.Warnf("Destroying GCP Bootstrap Resources")
229-
metadata, err := metadata.Load(dir)
230-
if err != nil {
231-
return err
232-
}
233-
if err := gcp.DestroyStorage(context.Background(), metadata.ClusterID); err != nil {
234-
return fmt.Errorf("failed to destroy storage")
229+
if err := gcp.DestroyStorage(ctx, in.Metadata.InfraID); err != nil {
230+
return fmt.Errorf("failed to destroy storage: %w", err)
235231
}
236232
return nil
237233
}

0 commit comments

Comments
 (0)