From 683cc7c59cc04be925b332c9707fbd8de67bbe23 Mon Sep 17 00:00:00 2001 From: Jiafeng Liao Date: Wed, 21 Dec 2022 11:25:26 -0800 Subject: [PATCH] [PWX-27765] Fix migration status update issue --- pkg/migration/migration.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pkg/migration/migration.go b/pkg/migration/migration.go index 688528a68..baaca6438 100644 --- a/pkg/migration/migration.go +++ b/pkg/migration/migration.go @@ -220,6 +220,20 @@ func (h *Handler) processMigration( // TODO: Wait for all components to be up, before marking the migration as completed + // Mark migration as completed in the cluster condition list + updatedCluster = &corev1.StorageCluster{} + if err := h.client.Get(context.TODO(), types.NamespacedName{Name: cluster.Name, Namespace: cluster.Namespace}, updatedCluster); err != nil { + return err + } + util.UpdateStorageClusterCondition(updatedCluster, &corev1.ClusterCondition{ + Source: pxutil.PortworxComponentName, + Type: corev1.ClusterConditionTypeMigration, + Status: corev1.ClusterConditionStatusCompleted, + }) + if err := k8sutil.UpdateStorageClusterStatus(h.client, updatedCluster); err != nil { + return err + } + // TODO: once daemonset is deleted, if we restart operator all code after this line // will not be re-executed, so we should delete daemonset after everything is finished. logrus.Infof("Deleting portworx DaemonSet") @@ -238,16 +252,6 @@ func (h *Handler) processMigration( // this cluster is a result of migration. After we have added that we can remove the // migration-approved annotation after a successful migration. - // Mark migration as completed in the cluster condition list - util.UpdateStorageClusterCondition(updatedCluster, &corev1.ClusterCondition{ - Source: pxutil.PortworxComponentName, - Type: corev1.ClusterConditionTypeMigration, - Status: corev1.ClusterConditionStatusCompleted, - }) - if err := k8sutil.UpdateStorageClusterStatus(h.client, updatedCluster); err != nil { - return err - } - return nil }