From d3045a1e2c613af1f75f79218606d451e7b9f7c1 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Thu, 14 Sep 2023 00:29:49 +0300 Subject: [PATCH] Update existing MCV if needed During upgrade we may have MCVs created by older version using resource instead of kind+group+version. Update existing MCVs to to the new format on the first time we access them. This adds a new log showing the updated scope: 2023-09-13T21:13:26.087Z INFO MCV util/mcv_util.go:334 Updating ManagedClusterView dr1/busybox-drpc-busybox-sample-vrg-mcv scope {Group: Version: Kind: Resource:VolumeReplicationGroup Name:busybox-drpc Namespace:busybox-sample UpdateIntervalSeconds:0} to {Group:ramendr.openshift.io Version:v1alpha1 Kind:VolumeReplicationGroup Resource: Name:busybox-drpc Namespace:busybox-sample UpdateIntervalSeconds:0} {"resourceName": "busybox-drpc"} We expect to the see this log once after an upgrade. If the MCV is modified manually, ramen will revert the change and log this again (this how I generated this log). Signed-off-by: Nir Soffer --- controllers/util/mcv_util.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/controllers/util/mcv_util.go b/controllers/util/mcv_util.go index e3b8d8af7..f48ff5407 100644 --- a/controllers/util/mcv_util.go +++ b/controllers/util/mcv_util.go @@ -330,7 +330,14 @@ func (m ManagedClusterViewGetterImpl) getOrCreateManagedClusterView( } if mcv.Spec.Scope != viewscope { - logger.Info("WARNING: existing ManagedClusterView has different ViewScope than desired one") + // Expected once when uprading ramen if scope format or details have changed. + logger.Info(fmt.Sprintf("Updating ManagedClusterView %s scope %+v to %+v", + key, mcv.Spec.Scope, viewscope)) + + mcv.Spec.Scope = viewscope + if err := m.Update(context.TODO(), mcv); err != nil { + return nil, errorswrapper.Wrap(err, "failed to update ManagedClusterView") + } } return mcv, nil