Skip to content

Commit

Permalink
Continue updating deployment manifests when uninstalling
Browse files Browse the repository at this point in the history
This allows an addon to update its deployment manifests while the
predelete hook is running. This is useful when telling the addon to
enter uninstall mode.

Additionally, if there is a bug in the uninstall and it keeps the
uninstall from succeeding, we need to allow container image updates to move
forward in the event the update fixes the problem.

Relates:
https://issues.redhat.com/browse/ACM-8947

Signed-off-by: mprahl <mprahl@users.noreply.github.com>
  • Loading branch information
mprahl committed Dec 7, 2023
1 parent 3bfdbff commit e30130d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
18 changes: 11 additions & 7 deletions pkg/addonmanager/controllers/agentdeploy/default_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ func (s *defaultSyncer) sync(ctx context.Context,

var errs []error

if !addon.DeletionTimestamp.IsZero() {
return addon, nil
}
// Don't skip syncing if the addon is deleting and there is a predelete hook, since the deployment manifests may
// need to be updated during the uninstall.
if !addonHasFinalizer(addon, addonapiv1alpha1.AddonPreDeleteHookFinalizer) {
if !addon.DeletionTimestamp.IsZero() {
return addon, nil
}

// waiting for the addon to be deleted when cluster is deleting.
// TODO: consider to delete addon in this scenario.
if !cluster.DeletionTimestamp.IsZero() {
return addon, nil
// waiting for the addon to be deleted when cluster is deleting.
// TODO: consider to delete addon in this scenario.
if !cluster.DeletionTimestamp.IsZero() {
return addon, nil
}
}

currentWorks, err := s.getWorkByAddon(addon.Name, addon.Namespace)
Expand Down
37 changes: 18 additions & 19 deletions pkg/addonmanager/controllers/agentdeploy/hosted_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,37 +80,36 @@ func (s *hostedSyncer) sync(ctx context.Context,
Message: fmt.Sprintf("hosting cluster %s is a managed cluster of the hub", hostingClusterName),
})

if !hostingCluster.DeletionTimestamp.IsZero() {
if err = s.cleanupDeployWork(ctx, addon); err != nil {
return addon, err
// Don't skip syncing if the addon is deleting and there is a predelete hook, since the deployment manifests may
// need to be updated during the uninstall.
if !addonHasFinalizer(addon, addonapiv1alpha1.AddonHostingPreDeleteHookFinalizer) {
if !hostingCluster.DeletionTimestamp.IsZero() {
if err = s.cleanupDeployWork(ctx, addon); err != nil {
return addon, err
}
addonRemoveFinalizer(addon, addonapiv1alpha1.AddonHostingManifestFinalizer)
return addon, nil
}
addonRemoveFinalizer(addon, addonapiv1alpha1.AddonHostingManifestFinalizer)
return addon, nil
}

if !addon.DeletionTimestamp.IsZero() {
// clean up the deploy work until the hook work is completed
if addonHasFinalizer(addon, addonapiv1alpha1.AddonHostingPreDeleteHookFinalizer) {
if !addon.DeletionTimestamp.IsZero() {
if err = s.cleanupDeployWork(ctx, addon); err != nil {
return addon, err
}
addonRemoveFinalizer(addon, addonapiv1alpha1.AddonHostingManifestFinalizer)
return addon, nil
}

if err = s.cleanupDeployWork(ctx, addon); err != nil {
return addon, err
// waiting for the addon to be deleted when cluster is deleting.
// TODO: consider to delete addon in this scenario.
if !cluster.DeletionTimestamp.IsZero() && !addonHasFinalizer(addon, addonapiv1alpha1.AddonHostingPreDeleteHookFinalizer) {
return addon, nil
}
addonRemoveFinalizer(addon, addonapiv1alpha1.AddonHostingManifestFinalizer)
return addon, nil
}

if addonAddFinalizer(addon, addonapiv1alpha1.AddonHostingManifestFinalizer) {
return addon, nil
}

// waiting for the addon to be deleted when cluster is deleting.
// TODO: consider to delete addon in this scenario.
if !cluster.DeletionTimestamp.IsZero() {
return addon, nil
}

currentWorks, err := s.getWorkByAddon(addon.Name, addon.Namespace)
if err != nil {
return addon, err
Expand Down

0 comments on commit e30130d

Please sign in to comment.