Skip to content

Commit

Permalink
Do not delete rsyslog MR if shoot is hibernated (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
plkokanov authored Apr 15, 2024
1 parent fad6b4f commit 648f297
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions pkg/controller/lifecycle/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,32 @@ type actuator struct {
func (a *actuator) Reconcile(ctx context.Context, _ logr.Logger, ex *extensionsv1alpha1.Extension) error {
namespace := ex.GetNamespace()

if err := deployMonitoringConfig(ctx, a.client, namespace); err != nil {
return err
}

cluster, err := extensionscontroller.GetCluster(ctx, a.client, namespace)
if err != nil {
return err
}

if cluster.Shoot == nil {
return errors.New("cluster.shoot is not yet populated")
}

// TODO(plkokanov): remove this after a couple releases.
if err := managedresources.DeleteForShoot(ctx, a.client, namespace, constants.ManagedResourceName); err != nil {
return err
}

timeoutCtx, cancelCtx := context.WithTimeout(ctx, deletionTimeout)
defer cancelCtx()
if err := managedresources.WaitUntilDeleted(timeoutCtx, a.client, namespace, constants.ManagedResourceName); err != nil {
return err
// Do not wait for the managed resource to be deleted
if extensionscontroller.IsHibernated(cluster) {
return nil
}

return deployMonitoringConfig(ctx, a.client, namespace)
timeoutCtx, cancelCtx := context.WithTimeout(ctx, deletionTimeout)
defer cancelCtx()
return managedresources.WaitUntilDeleted(timeoutCtx, a.client, namespace, constants.ManagedResourceName)
}

// Delete deletes the extension resource.
Expand Down Expand Up @@ -132,8 +146,7 @@ func (a *actuator) Migrate(ctx context.Context, _ logr.Logger, ex *extensionsv1a
return err
}

twoMinutes := time.Minute * 2
timeoutCtx, cancelCtx := context.WithTimeout(ctx, twoMinutes)
timeoutCtx, cancelCtx := context.WithTimeout(ctx, deletionTimeout)
defer cancelCtx()
return managedresources.WaitUntilDeleted(timeoutCtx, a.client, namespace, constants.ManagedResourceName)
}
Expand Down

0 comments on commit 648f297

Please sign in to comment.