Skip to content

Commit a85db0b

Browse files
committed
Infra Providers: add ctx to DestroyBootstrap
Adds a context to the DestroyBootstrap function in the infrastructure providers interface. The CAPI installer needs this if it restarts the CAPI control plane for the destroy bootstrap command.
1 parent 73a76ac commit a85db0b

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

pkg/destroy/bootstrap/bootstrap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func Destroy(ctx context.Context, dir string) (err error) {
8484
return fmt.Errorf("error getting infrastructure provider: %w", err)
8585
}
8686

87-
if err := provider.DestroyBootstrap(dir); err != nil {
87+
if err := provider.DestroyBootstrap(ctx, dir); err != nil {
8888
return fmt.Errorf("error destroying bootstrap resources %w", err)
8989
}
9090

pkg/infrastructure/aws/sdk/aws.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func (a InfraProvider) Provision(ctx context.Context, dir string, parents asset.
303303
}
304304

305305
// DestroyBootstrap destroys the temporary bootstrap resources.
306-
func (a InfraProvider) DestroyBootstrap(dir string) error {
306+
func (a InfraProvider) DestroyBootstrap(ctx context.Context, dir string) error {
307307
// Unmarshall input from tf variables, so we can use it along with
308308
// installConfig and other assets as the contractual input regardless of
309309
// the implementation.
@@ -341,7 +341,7 @@ func (a InfraProvider) DestroyBootstrap(dir string) error {
341341
Fn: request.MakeAddToUserAgentHandler("OpenShift/4.x Destroyer", version.Raw),
342342
})
343343

344-
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
344+
ctx, cancel := context.WithTimeout(ctx, 30*time.Minute)
345345
defer cancel()
346346

347347
logger := logrus.StandardLogger()

pkg/infrastructure/baremetal/baremetal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (a Provider) Provision(ctx context.Context, dir string, parents asset.Paren
3333
}
3434

3535
// DestroyBootstrap destroys the temporary bootstrap resources.
36-
func (a Provider) DestroyBootstrap(dir string) error {
36+
func (a Provider) DestroyBootstrap(ctx context.Context, dir string) error {
3737
config, err := getConfig(dir)
3838
if err != nil {
3939
return fmt.Errorf("failed to get baremetal platform config: %w", err)

pkg/infrastructure/clusterapi/clusterapi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func (i *InfraProvider) Provision(ctx context.Context, dir string, parents asset
362362
}
363363

364364
// DestroyBootstrap destroys the temporary bootstrap resources.
365-
func (i *InfraProvider) DestroyBootstrap(dir string) error {
365+
func (i *InfraProvider) DestroyBootstrap(ctx context.Context, dir string) error {
366366
metadata, err := metadata.Load(dir)
367367
if err != nil {
368368
return err

pkg/infrastructure/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Provider interface {
1818
Provision(ctx context.Context, dir string, parents asset.Parents) ([]*asset.File, error)
1919

2020
// DestroyBootstrap destroys the temporary bootstrap resources.
21-
DestroyBootstrap(dir string) error
21+
DestroyBootstrap(ctx context.Context, dir string) error
2222

2323
// ExtractHostAddresses extracts the IPs of the bootstrap and control plane machines.
2424
ExtractHostAddresses(dir string, config *types.InstallConfig, ha *HostAddresses) error

pkg/terraform/terraform.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (p *Provider) Provision(_ context.Context, dir string, parents asset.Parent
8181
// DestroyBootstrap implements pkg/infrastructure/provider.DestroyBootstrap.
8282
// DestroyBootstrap iterates through each stage, and will run the destroy
8383
// command when defined on a stage.
84-
func (p *Provider) DestroyBootstrap(dir string) error {
84+
func (p *Provider) DestroyBootstrap(ctx context.Context, dir string) error {
8585
varFiles := []string{tfVarsFileName, tfPlatformVarsFileName}
8686
for _, stage := range p.stages {
8787
varFiles = append(varFiles, stage.OutputsFilename())

0 commit comments

Comments
 (0)