-
Notifications
You must be signed in to change notification settings - Fork 39
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
reclaimspace: add support for namespace annotation #350
Conversation
24489fc
to
c3308b7
Compare
6eb9da3
to
b79bbd7
Compare
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 looks good to me, Thanks!
@@ -91,6 +123,45 @@ func (r *PersistentVolumeClaimReconciler) Reconcile(ctx context.Context, req ctr | |||
|
|||
annotations := pvc.GetAnnotations() | |||
schedule, scheduleFound := getScheduleFromAnnotation(&logger, annotations) | |||
if !scheduleFound { |
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 quite a large if-block, with lots of (good!) notes. Did you consider making it a helper function?
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.
Reduced the code length in the block now, it should be good
} | ||
schedule, scheduleFound = getScheduleFromAnnotation(&logger, ns.Annotations) | ||
// if the schedule is found check driver supports the space reclamation. | ||
if scheduleFound { |
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 prefer a
if !scheduleFound {
break
}
check so that the remaining of this large if-statement does not need extra indenting.
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 break is only for for,switch statements right not for if
in golang 🤔 this should be simple now as I moved the whole check to a new helper function
b79bbd7
to
779f0f7
Compare
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.
changes look good to me,
some tiny changes to better explain the flow.
return ctrl.Result{}, err | ||
} | ||
schedule, scheduleFound = getScheduleFromAnnotation(&logger, ns.Annotations) | ||
// If the schedule is found check driver supports the space reclamation. |
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.
// If the schedule is found check driver supports the space reclamation. | |
// If the schedule is not found, check whether driver supports the space reclamation using | |
// annotation on ns and registered driver capability for decision on re queue. |
|
||
ok := r.supportsReclaimSpace(driver) | ||
if reclaimSpaceSupportedByDriver && !ok { | ||
logger.Info("Driver does not support spacereclamation, Reqeueing request", "DriverName", driver) |
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.Info("Driver does not support spacereclamation, Reqeueing request", "DriverName", driver) | |
logger.Info("Driver supports spacereclamation but driver is not registered in the connection pool, Reqeueing request", "DriverName", driver) |
779f0f7
to
4a573bf
Compare
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.
Thanks !
remoce CreateFunc predicate to accomudate reading annotations from the namespaces. Signed-off-by: Madhu Rajanna <[email protected]>
Currently, we only support the reclaimspace feature on the PVC annotation. However, this adds support for namespace annotations as well. If the required PVC annotation is missing, our controller will check if the necessary annotation is present on the namespace. If it is, the scheduling details will be retrieved from the namespace annotation and used to create the ReclaimspaceCronJob. It's important to note that the PVC annotation will take precedence over namespace annotations. Please be aware that we can only create a reclaimspaceCronJob if the annotation exists on the namespace. If an admin wants to update or remove the annotation on the namespace, the same action must be taken on all the PVCs within that namespace. Signed-off-by: Madhu Rajanna <[email protected]>
Updated the documentation for the namespace annotation for the ReclaimSpace operation. Signed-off-by: Madhu Rajanna <[email protected]>
4a573bf
to
14fa4e5
Compare
Currently, we only support the reclaimspace feature on the PVC annotation. However, this adds support for namespace annotations as well. If the required PVC annotation is missing, our controller will check if the necessary annotation is present on the namespace. If it is, the scheduling details will be retrieved from the namespace annotation and used to create the ReclaimspaceCronJob.
It's important to note that the PVC annotation will take precedence over namespace annotations.
Please be aware that we can only create a reclaimspaceCronJob if the annotation exists on the namespace. If an admin wants to update or remove the annotation on the namespace, the same action must be taken on all the PVCs within that namespace.
Signed-off-by: Madhu Rajanna [email protected]