Skip to content

reclaimspace: add support for namespace annotation#350

Merged
mergify[bot] merged 3 commits into
csi-addons:mainfrom
Madhu-1:namespace-space-reclaim
May 24, 2023
Merged

reclaimspace: add support for namespace annotation#350
mergify[bot] merged 3 commits into
csi-addons:mainfrom
Madhu-1:namespace-space-reclaim

Conversation

@Madhu-1

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

Copy link
Copy Markdown
Member

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

@mergify mergify Bot requested review from Rakshith-R, nixpanic 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
Comment thread controllers/csiaddons/persistentvolumeclaim_controller.go Outdated
@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

@Rakshith-R Rakshith-R left a comment

Copy link
Copy Markdown
Member

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!


annotations := pvc.GetAnnotations()
schedule, scheduleFound := getScheduleFromAnnotation(&logger, annotations)
if !scheduleFound {

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member

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
Copy Markdown
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

@Rakshith-R Rakshith-R left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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

@Rakshith-R Rakshith-R left a comment

Copy link
Copy Markdown
Member

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 <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>
@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
Nikhil-Ladha pushed a commit to Nikhil-Ladha/kubernetes-csi-addons that referenced this pull request Dec 8, 2025
Syncing latest changes from upstream main for kubernetes-csi-addons
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