-
Notifications
You must be signed in to change notification settings - Fork 1k
Add PBD and priority class support for Karmada operator #7015
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
Conversation
Summary of ChangesHello @jabellard, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the robustness and operational stability of the Karmada operator by introducing configurable support for Kubernetes Priority Classes and Pod Disruption Budgets (PDBs) via its Helm chart. These additions allow administrators to ensure the operator's critical components are prioritized during scheduling and maintain desired availability levels even during cluster maintenance or scaling events. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request adds support for priorityClassName and PodDisruptionBudget (PDB) to the Karmada operator Helm chart, which is a great feature for enhancing the reliability of operator deployments. The implementation is mostly correct, but I've found a potential issue in the PDB template logic. The current implementation doesn't correctly handle a value of 0 for minAvailable or maxUnavailable, which could lead to generating an invalid PDB resource or one with unintended behavior. I've provided a suggestion to make the template more robust by using toString for checks and adding a fail guard to ensure a valid PDB configuration is always present when enabled.
charts/karmada-operator/templates/karmada-operator-poddisruptionbudget.yaml
Outdated
Show resolved
Hide resolved
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7015 +/- ##
==========================================
- Coverage 46.60% 46.59% -0.01%
==========================================
Files 699 699
Lines 48182 48182
==========================================
- Hits 22453 22451 -2
Misses 24032 24032
- Partials 1697 1699 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
seanlaii
left a comment
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 for the contributions! Left some comments.
| {{- if .Values.operator.priorityClassName }} | ||
| priorityClassName: {{ .Values.operator.priorityClassName }} |
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.
nit:
| {{- if .Values.operator.priorityClassName }} | |
| priorityClassName: {{ .Values.operator.priorityClassName }} | |
| {{- with .Values.operator.priorityClassName }} | |
| priorityClassName: {{ . | quote }} |
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.
You feel strongly about this? What's the benefit of changing it?
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.
No, it is just more idiomatic. It's fine if you don't want to change it.
Normally, if is for condition check, and with is to check if the value is presented.
But I don't have strong opinion. The current behavior is correct.
| {{- if .Values.commonLabels }} | ||
| {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} | ||
| {{- end }} |
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.
nit:
| {{- if .Values.commonLabels }} | |
| {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} | |
| {{- end }} | |
| {{- with .Values.commonLabels }} | |
| {{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 4 }} | |
| {{- end }} |
| {{- if .Values.commonAnnotations }} | ||
| annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} | ||
| {{- end }} |
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.
nit:
| {{- if .Values.commonAnnotations }} | |
| annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} | |
| {{- end }} | |
| {{- with .Values.commonAnnotations }} | |
| annotations: {{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 4 }} | |
| {{- end }} |
| namespace: {{ .Release.Namespace }} | ||
| labels: {{- include "common.labels.standard" . | nindent 4 }} | ||
| app: {{ include "karmada.operator.fullname" . }} | ||
| {{- if .Values.commonLabels }} |
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.
Maybe we can provide commonLabels and commonAnnotations in values.yaml.
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'm just using the same labels used in the deployment to link it to the pbd.
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.
Although users can use it, we currently don't provide it in https://github.com/karmada-io/karmada/blob/master/charts/karmada-operator/values.yaml.
We can add something like https://github.com/karmada-io/karmada/blob/master/charts/karmada/values.yaml#L12-L18.
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 expands the spoce of the PR, which is why I'd prefer to not add add it as part of this work. Would like to keep things as minimal as possible.
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.
Sure, since we also don't have commonAnnotations in Karmada helm chart, I don't feel strongly on this. Feel free to ignore.
| metadata: | ||
| name: {{ include "karmada.operator.fullname" . }} | ||
| namespace: {{ .Release.Namespace }} | ||
| labels: {{- include "common.labels.standard" . | nindent 4 }} |
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.
Tag standard labels here: https://github.com/bitnami/charts/blob/main/bitnami/common/templates/_labels.tpl for info.
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'm just using the same labels used in the deployment to link it to the pbd.
| selector: | ||
| matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }} | ||
| app: {{ include "karmada.operator.fullname" . }} | ||
| {{- if .Values.operator.pdb.minAvailable | toString }} |
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 think we need to use hasKey since null value will be considered as true.
Maybe we can refer to cert-manager.
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.
@seanlaii , thanks for the ref o the cert-manager approach and for thinking about the edge cases, but don't think we need to worry about this one. This would be a falsy value, so that block would not get evaluated.
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.
Considering this case
minAvailable: null
maxAvailable: 1
the result will be
selector:
matchLabels:
minAvailable:
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.
Really? Let me try it.
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.
@seanlaii , thanks for catching this. Will push update.
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.
Just tried. Handling this weird edge case comes at the cost of the code becoming a lot of unreadable and requiring use more advanced stuff. I'm unsure if it's worth the tradeoff. hasKey also will not catch this. You have other ideas?
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.
Yeah, will probably need this
{{- $pdb := .Values.operator.pdb }}
{{- if and (hasKey $pdb "minAvailable") (ne $pdb.minAvailable null) (ne $pdb.minAvailable "") }}
minAvailable: {{ $pdb.minAvailable }}
{{- else if and (hasKey $pdb "maxUnavailable") (ne $pdb.maxUnavailable null) (ne $pdb.maxUnavailable "") }}
maxUnavailable: {{ $pdb.maxUnavailable }}
{{- end }}
I am OK to keep it to maintain the readability.
Could you add some comment in the values.yaml to inform the users? Thanks!
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.
Will add some instructions on how to have maxUnavailable be the field that takes precedence.
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.
Done
|
/assign |
seanlaii
left a comment
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.
LGTM
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: seanlaii The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Thanks |
|
@jabellard Thanks, I have no further comments. It would be perfect if you could squash your commits into one. |
Signed-off-by: Joe Nathan Abellard <[email protected]>
66b1b3e to
d80ef83
Compare
I rebased and squashed this; nothing has changed since the last review. /lgtm |
What type of PR is this?
/kind feature
What this PR does / why we need it: Please see this issue: #6973
Which issue(s) this PR fixes:
Fixes #6973
Special notes for your reviewer:
Does this PR introduce a user-facing change?: