diff --git a/cmd/upgrade/executor/resource.go b/cmd/upgrade/executor/resource.go index f1f888a4..9d2d7b16 100644 --- a/cmd/upgrade/executor/resource.go +++ b/cmd/upgrade/executor/resource.go @@ -152,6 +152,11 @@ func (u *UpgradeOptions) InitializeFromUpgradeTaskResource( case upgradeTaskCRObj.Spec.ResourceSpec.CStorVolume != nil: u.resourceKind = "cstorVolume" u.name = upgradeTaskCRObj.Spec.ResourceSpec.CStorVolume.PVName + + case upgradeTaskCRObj.Spec.ResourceSpec.CStorVolume != nil: + u.resourceKind = "jivaVolume" + u.name = upgradeTaskCRObj.Spec.ResourceSpec.JivaVolume.PVName + } return nil diff --git a/pkg/upgrade/patch/deployment.go b/pkg/upgrade/patch/deployment.go index 745ae989..da62ac4b 100644 --- a/pkg/upgrade/patch/deployment.go +++ b/pkg/upgrade/patch/deployment.go @@ -21,7 +21,6 @@ import ( "strings" "time" - retry "github.com/openebs/maya/pkg/util/retry" "github.com/pkg/errors" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -83,7 +82,7 @@ func (d *Deployment) Patch(from, to string) error { return nil } if version == from { - deployObj, err := d.Client.AppsV1().Deployments(d.Object.Namespace).Patch( + _, err := d.Client.AppsV1().Deployments(d.Object.Namespace).Patch( context.TODO(), d.Object.Name, types.StrategicMergePatchType, @@ -97,32 +96,28 @@ func (d *Deployment) Patch(from, to string) error { d.Object.Name, ) } - revision, err := deploymentutil.Revision(deployObj) - if err != nil { - return err - } - err = retry. - Times(60). - Wait(5 * time.Second). - Try(func(attempt uint) error { - deployObj, err1 := d.Client.AppsV1().Deployments(d.Object.Namespace). - Get(context.TODO(), d.Object.Name, metav1.GetOptions{}) - if err != nil { - return err1 - } - statusViewer := DeploymentStatusViewer{} - msg, rolledOut, err1 := statusViewer.Status(deployObj, revision+1) - if err1 != nil { - return err1 - } - klog.Info("rollout status: ", msg) - if !rolledOut { - return errors.Wrapf(err1, "failed to rollout: %s", msg) - } - return nil - }) - if err != nil { - return err + time.Sleep(2 * time.Second) + for { + deployObj, err1 := d.Client.AppsV1().Deployments(d.Object.Namespace). + Get(context.TODO(), d.Object.Name, metav1.GetOptions{}) + if err1 != nil { + return err1 + } + revision, err1 := deploymentutil.Revision(deployObj) + if err1 != nil { + return err1 + } + statusViewer := DeploymentStatusViewer{} + msg, rolledOut, err1 := statusViewer.Status(deployObj, revision) + if err1 != nil { + return err1 + } + klog.Info("rollout status: ", msg) + if !rolledOut { + time.Sleep(5 * time.Second) + } else { + break + } } klog.Infof("deployment %s patched successfully", d.Object.Name) } diff --git a/pkg/upgrade/patch/statefulset.go b/pkg/upgrade/patch/statefulset.go index a92b8927..b466f1d3 100644 --- a/pkg/upgrade/patch/statefulset.go +++ b/pkg/upgrade/patch/statefulset.go @@ -21,7 +21,6 @@ import ( "strings" "time" - retry "github.com/openebs/maya/pkg/util/retry" "github.com/pkg/errors" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -96,28 +95,23 @@ func (s *StatefulSet) Patch(from, to string) error { s.Object.Name, ) } - err = retry. - Times(60). - Wait(5 * time.Second). - Try(func(attempt uint) error { - stsObj, err1 := s.Client.AppsV1().StatefulSets(s.Object.Namespace). - Get(context.TODO(), s.Object.Name, metav1.GetOptions{}) - if err != nil { - return err1 - } - statusViewer := StatefulSetStatusViewer{} - msg, rolledOut, err1 := statusViewer.Status(stsObj) - if err1 != nil { - return err1 - } - klog.Info("rollout status: ", msg) - if !rolledOut { - return errors.Wrapf(err1, "failed to rollout: %s", msg) - } - return nil - }) - if err != nil { - return err + for { + stsObj, err1 := s.Client.AppsV1().StatefulSets(s.Object.Namespace). + Get(context.TODO(), s.Object.Name, metav1.GetOptions{}) + if err != nil { + return err1 + } + statusViewer := StatefulSetStatusViewer{} + msg, rolledOut, err1 := statusViewer.Status(stsObj) + if err1 != nil { + return err1 + } + klog.Info("rollout status: ", msg) + if !rolledOut { + time.Sleep(5 * time.Second) + } else { + break + } } klog.Infof("statefulset %s patched successfully", s.Object.Name) } diff --git a/pkg/upgrade/upgrader/jiva_volume.go b/pkg/upgrade/upgrader/jiva_volume.go index a58d1cd9..dbe464ed 100644 --- a/pkg/upgrade/upgrader/jiva_volume.go +++ b/pkg/upgrade/upgrader/jiva_volume.go @@ -277,7 +277,7 @@ func (obj *JivaVolumePatch) JivaVolumeUpgrade() (string, error) { func (obj *JivaVolumePatch) Upgrade() error { var err, uerr error obj.Utask, err = getOrCreateUpgradeTask( - "cstorVolume", + "jivaVolume", obj.ResourcePatch, obj.Client, ) diff --git a/pkg/upgrade/upgrader/upgradetask.go b/pkg/upgrade/upgrader/upgradetask.go index 8a638605..2ef704e0 100644 --- a/pkg/upgrade/upgrader/upgradetask.go +++ b/pkg/upgrade/upgrader/upgradetask.go @@ -156,6 +156,13 @@ func buildUpgradeTask(kind string, r *ResourcePatch) *v1Alpha1API.UpgradeTask { PVName: r.Name, }, } + case "jivaVolume": + utaskObj.Name = "upgrade-jiva-csi-volume-" + r.Name + utaskObj.Spec.ResourceSpec = v1Alpha1API.ResourceSpec{ + CStorVolume: &v1Alpha1API.CStorVolume{ + PVName: r.Name, + }, + } } return utaskObj }