Skip to content

Commit

Permalink
Touch the backup target CRs to migrate the API version before deleting
Browse files Browse the repository at this point in the history
longhorn-manager

This is needed because after Longhorn manager daemonset was
deleted (aka conversion webhook is not running), we cannot
delete CRs in older API version in deleteRecreatedCRs().

Signed-off-by: Phan Le <phan.le@suse.com>
  • Loading branch information
PhanLe1010 authored and innobead committed May 22, 2024
1 parent 1d1c828 commit 23ccdd1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions controller/uninstall_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,23 @@ func (c *UninstallController) uninstall() error {
if ready, err := c.managerReady(); err != nil {
return err
} else if ready {
// Hack: touch the backup target CRs to migrate the API version.
// This is needed because after Longhorn manager daemonset was
// deleted (aka conversion webhook is not running), we cannot
// delete CRs in older API version in deleteRecreatedCRs().
// TODO: A better solution for this issue would be touching
// and migrating API versions for all Longhorn CRs in the upgrade path
// or separating the conversion webhook from longhorn-manager daemonset
if backupTargets, err := c.ds.ListBackupTargets(); err != nil {
return err
} else if len(backupTargets) > 0 {
for _, bt := range backupTargets {
if _, err = c.ds.UpdateBackupTarget(bt); err != nil {
return errors.Wrap(err, "failed to touch the backup target CR for API version migration")
}
}
}

if waitForUpdate, err := c.deleteCRs(); err != nil || waitForUpdate {
return err
}
Expand Down

0 comments on commit 23ccdd1

Please sign in to comment.