reclaimspace: add support for namespace annotation#350
Conversation
24489fc to
c3308b7
Compare
6eb9da3 to
b79bbd7
Compare
Rakshith-R
left a comment
There was a problem hiding this comment.
This looks good to me, Thanks!
|
|
||
| annotations := pvc.GetAnnotations() | ||
| schedule, scheduleFound := getScheduleFromAnnotation(&logger, annotations) | ||
| if !scheduleFound { |
There was a problem hiding this comment.
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.
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.
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.
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
Rakshith-R
left a comment
There was a problem hiding this comment.
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.
| // 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.
| 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
remoce CreateFunc predicate to accomudate reading annotations from the namespaces. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
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 <madhupr007@gmail.com>
Updated the documentation for the namespace annotation for the ReclaimSpace operation. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
4a573bf to
14fa4e5
Compare
Syncing latest changes from upstream main for kubernetes-csi-addons
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 madhupr007@gmail.com