-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add option to disable KeyRotation #659
base: main
Are you sure you want to change the base?
Add option to disable KeyRotation #659
Conversation
TestingSteps❯ oc annotate sc/rook-ceph-block "keyrotation.csiaddons.openshift.io/disable=true"
storageclass.storage.k8s.io/rook-ceph-block annotated
❯ oc get encryptionkeyrotationcronjob
No resources found in rook-ceph namespace.
❯ oc annotate sc/rook-ceph-block "keyrotation.csiaddons.openshift.io/disable-"
storageclass.storage.k8s.io/rook-ceph-block annotated
❯ oc get encryptionkeyrotationcronjob
NAME SCHEDULE SUSPEND ACTIVE LASTSCHEDULE AGE
rbd-pvc-1725353742 @weekly 2s Logs
|
f0e7c46
to
1f38728
Compare
val, ok := annotations[annotation] | ||
if ok { | ||
return strings.ToLower(val) == "true", nil | ||
} |
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.
Please add a helper function for it as we have same check in 3 places
@@ -65,6 +65,7 @@ var ( | |||
rsCSIAddonsDriverAnnotation = "reclaimspace." + csiaddonsv1alpha1.GroupVersion.Group + "/drivers" | |||
|
|||
krcJobScheduleTimeAnnotation = "keyrotation." + csiaddonsv1alpha1.GroupVersion.Group + "/schedule" | |||
krcJobDisableAnnotation = "keyrotation." + csiaddonsv1alpha1.GroupVersion.Group + "/disable" |
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.
/enable
instead of disable. This is the one we are considering for reclaimspace as well.
logger.Error(err, "failed to delete child encryptionkeyrotationcronjob") | ||
|
||
return fmt.Errorf("failed to delete child encryptionkeyrotationcronjob: %w", err) |
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.
logger.Error(err, "failed to delete child encryptionkeyrotationcronjob") | |
return fmt.Errorf("failed to delete child encryptionkeyrotationcronjob: %w", err) | |
errMsg:=""failed to delete child encryptionkeyrotationcronjob" | |
logger.Error(err, errMsg) | |
return fmt.Errorf(%s: %w",errMsg, err) |
1f38728
to
03c777a
Compare
This patch adds the feature to disable key rotation by annotating either of NS, SC or PVC. The annotation to be used is: `keyrotation.csiaddons.openshift.io/disable=true` Signed-off-by: Niraj Yadav <[email protected]>
03c777a
to
b457994
Compare
@@ -65,6 +65,7 @@ var ( | |||
rsCSIAddonsDriverAnnotation = "reclaimspace." + csiaddonsv1alpha1.GroupVersion.Group + "/drivers" | |||
|
|||
krcJobScheduleTimeAnnotation = "keyrotation." + csiaddonsv1alpha1.GroupVersion.Group + "/schedule" | |||
krcJobDisableAnnotation = "keyrotation." + csiaddonsv1alpha1.GroupVersion.Group + "/enable" |
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.
The name contains Disable
, but the value ends with /enable
. This is a little confusing.
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.
Right. I'll edit the name and logic accordingly.
@@ -717,6 +723,62 @@ func (r *PersistentVolumeClaimReconciler) findChildEncryptionKeyRotationCronJob( | |||
return activeJob, nil | |||
} | |||
|
|||
// checkDisabledAnnotation checks if the annotation is set in the | |||
// PVC, namespace or the storage class. It returns true if the | |||
// annotation is set to `false`. |
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.
Quite a confusing description if someone does not know the disabled annotation ends with /enabled
. Please read it back to yourself, while you forgot the actual annotation key.
|
||
// Check StorageClass | ||
sc := &storagev1.StorageClass{} | ||
err = r.Client.Get(ctx, types.NamespacedName{Name: *pvc.Spec.StorageClassName}, sc) |
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.
StorageClasses are not namespaced, is there an alternative to types.NamespacedName
?
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, we can use client.ObjectKeyFromObject
or client.ObjectKey
instead.
Also don't forget to add the new annotation to the documentation! |
This patch adds the feature to disable key
rotation by annotating any of NS, SC or PVC.
The annotation to be used is:
keyrotation.csiaddons.openshift.io/disable=true