Skip to content

Commit

Permalink
Skip Loadbalancer Calls during deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
maboehm authored and Lukas Hoehl committed Apr 5, 2024
1 parent fbd78ac commit b7fc370
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
31 changes: 18 additions & 13 deletions pkg/controller/infrastructure/actuator_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,13 @@ func (a *actuator) deleteWithTerraformer(ctx context.Context, log logr.Logger, i
if err != nil {
return util.DetermineError(err, helper.KnownCodes)
}
loadbalancerClient, err := openstackClient.Loadbalancing()
if err != nil {
return util.DetermineError(err, helper.KnownCodes)
}

// STACKIT Openstack has no Loadbalancer API, so we are skipping this call, see
// https://github.com/gardener/gardener-extension-provider-openstack/issues/672
// loadbalancerClient, err := openstackClient.Loadbalancing()
// if err != nil {
// return util.DetermineError(err, helper.KnownCodes)
// }

stateInitializer := terraformer.StateConfigMapInitializerFunc(terraformer.CreateState)
tf = tf.InitializeWith(ctx, terraformer.DefaultInitializer(a.client, terraformFiles.Main, terraformFiles.Variables, terraformFiles.TFVars, stateInitializer)).SetEnvVars(internal.TerraformerEnvVars(infra.Spec.SecretRef, credentials)...)
Expand All @@ -130,14 +133,16 @@ func (a *actuator) deleteWithTerraformer(ctx context.Context, log logr.Logger, i
}

var (
g = flow.NewGraph("Openstack infrastructure destruction")
destroyKubernetesLoadbalancers = g.Add(flow.Task{
Name: "Destroying Kubernetes loadbalancers entries",
Fn: flow.TaskFn(func(ctx context.Context) error {
return a.cleanupKubernetesLoadbalancers(ctx, log, loadbalancerClient, vars[infrastructure.TerraformOutputKeySubnetID], infra.Namespace)
}).RetryUntilTimeout(10*time.Second, 5*time.Minute),
SkipIf: !configExists,
})
g = flow.NewGraph("Openstack infrastructure destruction")
// STACKIT Openstack has no Loadbalancer API, so we are skipping this call, see
// https://github.com/gardener/gardener-extension-provider-openstack/issues/672
// destroyKubernetesLoadbalancers = g.Add(flow.Task{
// Name: "Destroying Kubernetes loadbalancers entries",
// Fn: flow.TaskFn(func(ctx context.Context) error {
// return a.cleanupKubernetesLoadbalancers(ctx, log, loadbalancerClient, vars[infrastructure.TerraformOutputKeySubnetID], infra.Namespace)
// }).RetryUntilTimeout(10*time.Second, 5*time.Minute),
// SkipIf: !configExists,
// })
destroyKubernetesRoutes = g.Add(flow.Task{
Name: "Destroying Kubernetes route entries",
Fn: flow.TaskFn(func(ctx context.Context) error {
Expand All @@ -149,7 +154,7 @@ func (a *actuator) deleteWithTerraformer(ctx context.Context, log logr.Logger, i
_ = g.Add(flow.Task{
Name: "Destroying Shoot infrastructure",
Fn: tf.Destroy,
Dependencies: flow.NewTaskIDs(destroyKubernetesRoutes, destroyKubernetesLoadbalancers),
Dependencies: flow.NewTaskIDs(destroyKubernetesRoutes),
})

f = g.Compile()
Expand Down
17 changes: 10 additions & 7 deletions pkg/controller/infrastructure/infraflow/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ func NewFlowContext(log logr.Logger, clientFactory osclient.Factory,
if err != nil {
return nil, fmt.Errorf("creating compute client failed: %w", err)
}
loadbalancing, err := clientFactory.Loadbalancing(osclient.WithRegion(infra.Spec.Region))
if err != nil {
return nil, err
}

// STACKIT Openstack has no Loadbalancer API, so we are skipping this call, see
// https://github.com/gardener/gardener-extension-provider-openstack/issues/672
// loadbalancing, err := clientFactory.Loadbalancing(osclient.WithRegion(infra.Spec.Region))
// if err != nil {
// return nil, err
// }

flowContext := &FlowContext{
BasicFlowContext: *shared.NewBasicFlowContext(log, whiteboard, persistor),
Expand All @@ -112,9 +115,9 @@ func NewFlowContext(log logr.Logger, clientFactory osclient.Factory,
config: config,
cloudProfileConfig: cloudProfileConfig,
networking: networking,
loadbalancing: loadbalancing,
access: access,
compute: compute,
// loadbalancing: loadbalancing,
access: access,
compute: compute,
}
return flowContext, nil
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/controller/infrastructure/infraflow/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ func (c *FlowContext) buildDeleteGraph() *flow.Graph {
if subnetID == nil {
return nil
}
return infrastructure.CleanupKubernetesLoadbalancers(ctx, c.LogFromContext(ctx), c.loadbalancing, *subnetID, c.namespace)
// STACKIT Openstack has no Loadbalancer API, so we are skipping this call, see
// https://github.com/gardener/gardener-extension-provider-openstack/issues/672
// return infrastructure.CleanupKubernetesLoadbalancers(ctx, c.LogFromContext(ctx), c.loadbalancing, *subnetID, c.namespace)
return nil
},
Timeout(defaultTimeout),
)
Expand Down

0 comments on commit b7fc370

Please sign in to comment.