Skip to content

controller: fix reclaimspace based on ns annotation#396

Merged
mergify[bot] merged 1 commit into
csi-addons:mainfrom
Rakshith-R:ns-annotate-fix
Jun 28, 2023
Merged

controller: fix reclaimspace based on ns annotation#396
mergify[bot] merged 1 commit into
csi-addons:mainfrom
Rakshith-R:ns-annotate-fix

Conversation

@Rakshith-R

Copy link
Copy Markdown
Member

Logic used for determining reclaimspace annotation based on ns annotation and driver support had a bug which caused all the PVCs regardless of driversupport being annotated.
This commit makes sure only pvc with driver which
support reclaimspace is annotated/ requeued.

@Rakshith-R Rakshith-R requested review from Madhu-1 and nixpanic June 27, 2023 11:57
@mergify mergify Bot requested a review from yati1998 June 27, 2023 11:57
@Rakshith-R Rakshith-R added this to the release-v0.6.0 milestone Jun 27, 2023
}
schedule, scheduleFound = getScheduleFromAnnotation(&logger, ns.Annotations)
// If the schedule is not found, check whether driver supports the
nsSchedule, nsScheduleFound := getScheduleFromAnnotation(&logger, ns.Annotations)

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.

Do we need new variables? Can we assign this to exist schedule,schduleFound?

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.

Do we need new variables? Can we assign this to exist schedule,schduleFound?

This current form simplifies the code and makes it easier to understand,
Otherwise it was very difficult to follow the flow.
please read the comments inside the statements.

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.

hmm, this change does not improve the function for me. I have read the comments and change a few times now (that was really needed to understand it), so I think it is not clear enough. If you want to improve the behaviour, split things out in helper functions instead.

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.

We are evaluating a lot of conditions in these statements,

I don't believe adding helper function which take in a lot of arguments and also return a lot of arguments will make the code flow any cleaner.

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.

Moved the statements into a helper function with lots of io args.
Hopefully it is simpler to follow now 🤞

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! I am not a big fan of many return values or arguments to a function either, but this is definitely easier to understand than what there was before.

One thing that could make it even cleaner, is returning an error if requeuing shoud not be needed. This, and maybe the schedule-not-found could be pre-defined errors. You can then check with errors.Is(...) what early return from the reconcile should be done. Can you consider doing that, and see if it makes it even cleaner?

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.

made the suggested changes, ptal.

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.

Both the args are now Err types and will be detected using errors.Is().

@Rakshith-R Rakshith-R requested a review from Madhu-1 June 27, 2023 12:02
Madhu-1
Madhu-1 previously approved these changes Jun 27, 2023
@Rakshith-R Rakshith-R requested review from nixpanic and removed request for nixpanic June 27, 2023 13:08
@Rakshith-R

Copy link
Copy Markdown
Member Author

@Mergifyio rebase

@mergify

mergify Bot commented Jun 27, 2023

Copy link
Copy Markdown

rebase

✅ Branch has been successfully rebased

@Rakshith-R Rakshith-R force-pushed the ns-annotate-fix branch 2 times, most recently from d51a9dc to f344e4d Compare June 28, 2023 07:40
@mergify mergify Bot dismissed Madhu-1’s stale review June 28, 2023 07:41

Pull request has been modified.

Logic used for determining reclaimspace annotation
based on ns annotation and driver support had a bug
which caused all the PVCs regardless of driversupport
being annotated.
This commit makes sure only pvc with driver which
support reclaimspace is annotated/ requeued.

Signed-off-by: Rakshith R <rar@redhat.com>
@Rakshith-R Rakshith-R requested a review from Madhu-1 June 28, 2023 07:54
@mergify mergify Bot merged commit bed9c6e into csi-addons:main Jun 28, 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