-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generates VolRepClasses based on the RamenDR replication schedule resource #177
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: raaizik The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
597255c
to
7a6fc7b
Compare
626d539
to
f0ceee7
Compare
08910fd
to
8ee12ce
Compare
VolRepClass
based on the RamenDR replication schedule resource
66dca4f
to
27ee9da
Compare
VolRepClass
based on the RamenDR replication schedule resource
Depends on #2727 |
Testing:
@Madhu-1 could you verify that vrc has the right parameters/labels/annotations? |
@rewantsoni parameters looks good, am not sure about the annotations/labels |
@@ -424,6 +469,44 @@ func (r *StorageClaimReconciler) reconcilePhases() (reconcile.Result, error) { | |||
if err != nil { | |||
return reconcile.Result{}, fmt.Errorf("failed to create or update VolumeSnapshotClass: %s", err) | |||
} | |||
case "VolumeReplicationClass": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when the drClusterConfig is deleted? Will the VRC's get deleted as well?
a640d1e
to
8de6b52
Compare
} | ||
// check if DRClusterConfig has been removed | ||
if len(drclusterconfigs.Items) == 0 { | ||
vrcs := &replicationv1alpha1.VolumeReplicationClassList{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just set the owneRef of VolumeReplicationClass as the drclusterconfig as both are clusterscoped resouces?
} | ||
} | ||
drclusterconfig := &drclusterconfigs.Items[0] | ||
for interval := range drclusterconfig.Spec.ReplicationSchedules { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what will happen when specific ReplicationSchedules are deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed that, added ✔️
0b2bdcd
to
203fc57
Compare
if err != nil { | ||
return reconcile.Result{}, fmt.Errorf("failed to get VolumeReplicationClassList: %v", err) | ||
} | ||
drclusterconfig := &drclusterconfigs.Items[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail if the len(drclusterconfigs.Items) is zero
@@ -141,8 +192,9 @@ func (r *StorageClaimReconciler) SetupWithManager(mgr ctrl.Manager) error { | |||
//+kubebuilder:rbac:groups=snapshot.storage.k8s.io,resources=volumesnapshotclasses,verbs=get;list;watch;create;delete | |||
//+kubebuilder:rbac:groups=core,resources=persistentvolumes,verbs=get;list;watch | |||
//+kubebuilder:rbac:groups=snapshot.storage.k8s.io,resources=volumesnapshotcontents,verbs=get;list;watch | |||
//+kubebuilder:rbac:groups=ramendr.openshift.io,resources=drclusterconfigs,verbs=get;list;watch | |||
//+kubebuilder:rbac:groups=replication.storage.openshift.io,resources=volumereplicationclass,verbs=get;list;watch;create;delete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you run make bundle after updating the rbac?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
if len(drclusterconfigs.Items) == 0 { | ||
return reconcile.Result{}, fmt.Errorf("no DRClusterConfig found") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not an error, it means that we don't need to create VRC.
enqueueStorageClaim := handler.EnqueueRequestsFromMapFunc( | ||
func(_ context.Context, _ client.Object) []reconcile.Request { | ||
sclaims := &v1alpha1.StorageClaimList{} | ||
err := r.list(sclaims) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls use the supplied context r.List(ctx, ...)
as the ctx on reconciler may be empty at this point and when cancelled this may panic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean use r.Client.List()
. This won't be consistent with the rest of the code that does use the aux wrapper functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Client is embedded inside reconciler and all methods on that will be available to reconciler, anyways I don't have a problem w/ how that'll be referred.
I'm not taking about consistency but of correctness, you can see the wrapper functions are used inside Reconcile and at the start of it r.ctx
will be defined but in here that isn't the case.
err = r.list(drclusterconfigs) | ||
if err != nil { | ||
return reconcile.Result{}, fmt.Errorf("failed to get DRClusterConfigList: %v", err) | ||
} | ||
if len(drclusterconfigs.Items) == 0 { | ||
continue | ||
} | ||
if len(drclusterconfigs.Items) > 1 { | ||
return reconcile.Result{}, fmt.Errorf("there's more than one DRClusterConfig attached to the cluster") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err = r.list(drclusterconfigs) | |
if err != nil { | |
return reconcile.Result{}, fmt.Errorf("failed to get DRClusterConfigList: %v", err) | |
} | |
if len(drclusterconfigs.Items) == 0 { | |
continue | |
} | |
if len(drclusterconfigs.Items) > 1 { | |
return reconcile.Result{}, fmt.Errorf("there's more than one DRClusterConfig attached to the cluster") | |
} | |
if err := r.list(drclusterconfigs) && err != nil { | |
return reconcile.Result{}, fmt.Errorf("failed to get DRClusterConfigList: %v", err) | |
} else if len(drclusterconfigs.Items) == 0 { | |
continue | |
} else if len(drclusterconfigs.Items) > 1 { | |
return reconcile.Result{}, fmt.Errorf("there's more than one DRClusterConfig attached to the cluster") | |
} |
these conditions seems to be all inclusive and could be grouped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely you meant: (can't use else
keyword here at all)
if err := r.list(drclusterconfigs); err != nil {
return reconcile.Result{}, fmt.Errorf("failed to get DRClusterConfigList: %v", err)
}
if len(drclusterconfigs.Items) == 0 {
continue
}
if len(drclusterconfigs.Items) > 1 {
return reconcile.Result{}, fmt.Errorf("there's more than one DRClusterConfig attached to the cluster")
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant what I suggested, didn't get what you mean by else
part though. I mentioned else-if as the conditions are all inclusive, ex: when err is nil items len can't be 0 and > 1 at the same time.
- Creates VolRepClass in response to changes made to DRClusterConfig - k8s csi addons bump Signed-off-by: raaizik <[email protected]>
Changess
VolumeReplicationClass
in response to changes made toDRClusterConfig
-- the RamenDR replication schedule CR. VRCs are generated per each sched interval detailed inDRClusterConfig
, for both flatten and non-flatten mode VRC types.RHSTOR-5753