Skip to content

Commit

Permalink
upgrade: set instanceManager.spec.desireState to running
Browse files Browse the repository at this point in the history
Longhorn 8456

Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit committed Apr 27, 2024
1 parent 6fe2da2 commit 9f9fd92
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions upgrade/v16xto170/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ func UpgradeResources(namespace string, lhClient *lhclientset.Clientset, kubeCli
return err
}

return upgradeNodes(namespace, lhClient, resourceMaps)
if err := upgradeNodes(namespace, lhClient, resourceMaps); err != nil {
return err
}

return upgradeInstanceManagers(namespace, lhClient, resourceMaps)
}

func UpgradeResourcesStatus(namespace string, lhClient *lhclientset.Clientset, kubeClient *clientset.Clientset, resourceMaps map[string]interface{}) error {
Expand Down Expand Up @@ -116,7 +120,7 @@ func upgradeEngineStatus(namespace string, lhClient *lhclientset.Clientset, reso

func upgradeNodes(namespace string, lhClient *lhclientset.Clientset, resourceMaps map[string]interface{}) (err error) {
defer func() {
err = errors.Wrapf(err, upgradeLogPrefix+"upgrade node failed")
err = errors.Wrapf(err, upgradeLogPrefix+"upgrade nodes failed")
}()

nodeMap, err := upgradeutil.ListAndUpdateNodesInProvidedCache(namespace, lhClient, resourceMaps)
Expand All @@ -142,3 +146,23 @@ func upgradeNodes(namespace string, lhClient *lhclientset.Clientset, resourceMap

return nil
}

func upgradeInstanceManagers(namespace string, lhClient *lhclientset.Clientset, resourceMaps map[string]interface{}) (err error) {
defer func() {
err = errors.Wrapf(err, upgradeLogPrefix+"upgrade instance managers failed")
}()

imMap, err := upgradeutil.ListAndUpdateInstanceManagersInProvidedCache(namespace, lhClient, resourceMaps)
if err != nil {
if apierrors.IsNotFound(err) {
return nil
}
return errors.Wrapf(err, "failed to list all existing Longhorn instance managers during the instance manager upgrade")
}

for _, im := range imMap {
im.Spec.DesireState = longhorn.InstanceManagerStateRunning
}

return nil
}

0 comments on commit 9f9fd92

Please sign in to comment.