Skip to content

Commit

Permalink
Suspending HMC helm release before deletion
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Pavlov <[email protected]>
  • Loading branch information
Kshatrix committed Aug 9, 2024
1 parent 261267c commit 3a4e751
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/controller/management_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ func (r *ManagementReconciler) Delete(ctx context.Context, management *hmc.Manag
var errs error
l.Info("Removing Management components")
for _, component := range components {
if component.Template == management.Spec.Core.HMC.Template {
// This one has to be removed manually
continue
}
lc := l.WithValues("component", component.Component.Template)
lc.Info("Processing Management component removal")
hr := &v2.HelmRelease{}
Expand All @@ -160,6 +156,15 @@ func (r *ManagementReconciler) Delete(ctx context.Context, management *hmc.Manag
continue
}
if hr.ObjectMeta.DeletionTimestamp.IsZero() {
if component.Template == management.Spec.Core.HMC.Template {
lc.Info("Suspending HelmRelease")
// This one has to be removed manually. HelmRelease is marked as suspended before deletion.
hr.Spec.Suspend = true
if err := r.Client.Update(ctx, hr); err != nil {
errs = errors.Join(err)
continue
}
}
lc.Info("Removing HelmRelease")
err := r.Client.Delete(ctx, hr)
if err != nil && !apierrors.IsNotFound(err) {
Expand Down

0 comments on commit 3a4e751

Please sign in to comment.