Skip to content

Commit

Permalink
Update existing MCV if needed
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nirs authored and ShyamsundarR committed Oct 2, 2023
1 parent c213541 commit d3045a1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion controllers/util/mcv_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d3045a1

Please sign in to comment.