Skip to content
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

Merged
merged 3 commits into from
May 24, 2023

Conversation

Madhu-1
Copy link
Member

@Madhu-1 Madhu-1 commented May 15, 2023

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]

@mergify mergify bot requested review from nixpanic, Rakshith-R and yati1998 May 15, 2023 08:56
@Madhu-1 Madhu-1 force-pushed the namespace-space-reclaim branch from 24489fc to c3308b7 Compare May 15, 2023 08:57
@Madhu-1 Madhu-1 requested a review from Rakshith-R May 16, 2023 08:31
@Madhu-1 Madhu-1 force-pushed the namespace-space-reclaim branch 2 times, most recently from 6eb9da3 to b79bbd7 Compare May 16, 2023 10:52
Rakshith-R
Rakshith-R previously approved these changes May 16, 2023
Copy link
Member

@Rakshith-R Rakshith-R left a 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 {
Copy link
Collaborator

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?

Copy link
Member Author

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 {
Copy link
Collaborator

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.

Copy link
Member Author

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

@Madhu-1 Madhu-1 force-pushed the namespace-space-reclaim branch from b79bbd7 to 779f0f7 Compare May 17, 2023 08:33
@mergify mergify bot dismissed Rakshith-R’s stale review May 17, 2023 08:34

Pull request has been modified.

@Madhu-1 Madhu-1 requested a review from nixpanic May 17, 2023 08:34
Copy link
Member

@Rakshith-R Rakshith-R left a 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

@Madhu-1 Madhu-1 force-pushed the namespace-space-reclaim branch from 779f0f7 to 4a573bf Compare May 22, 2023 06:51
@Madhu-1 Madhu-1 requested a review from Rakshith-R May 22, 2023 06:51
Copy link
Member

@Rakshith-R Rakshith-R left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

Madhu-1 added 3 commits May 24, 2023 07:16
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]>
@Madhu-1 Madhu-1 force-pushed the namespace-space-reclaim branch from 4a573bf to 14fa4e5 Compare May 24, 2023 07:16
@mergify mergify bot merged commit c0e4402 into csi-addons:main May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants