Skip to content

[LFXV2-1166] Add pod disruption budget support#47

Open
bramwelt wants to merge 3 commits intomainfrom
tbramwell/LFXV2-1166-pod-disruption-budget
Open

[LFXV2-1166] Add pod disruption budget support#47
bramwelt wants to merge 3 commits intomainfrom
tbramwell/LFXV2-1166-pod-disruption-budget

Conversation

@bramwelt
Copy link
Contributor

@bramwelt bramwelt commented Mar 6, 2026

Summary

  • Add podDisruptionBudget values to Helm chart (disabled by default)
  • Create PodDisruptionBudget template supporting minAvailable and maxUnavailable

🤖 Generated with Claude Code

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1166
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
@bramwelt bramwelt requested a review from a team as a code owner March 6, 2026 18:44
Copilot AI review requested due to automatic review settings March 6, 2026 18:44
@coderabbitai
Copy link

coderabbitai bot commented Mar 6, 2026

Walkthrough

A new PodDisruptionBudget template and corresponding Helm values are added to enable optional pod disruption budget configuration. The template conditionally renders the PDB resource with validation to prevent simultaneous specification of minAvailable and maxUnavailable constraints.

Changes

Cohort / File(s) Summary
PodDisruptionBudget Support
charts/lfx-v2-project-service/templates/pdb.yaml, charts/lfx-v2-project-service/values.yaml
Introduces PodDisruptionBudget template with conditional deployment, validation preventing simultaneous minAvailable/maxUnavailable configuration, and corresponding configuration values (enabled flag and optional minAvailable/maxUnavailable placeholders).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and concisely summarizes the main change: adding pod disruption budget support to the Helm chart.
Description check ✅ Passed The pull request description is directly related to the changeset, explaining the addition of podDisruptionBudget values and the PodDisruptionBudget template with minAvailable and maxUnavailable support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tbramwell/LFXV2-1166-pod-disruption-budget

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds PodDisruptionBudget (PDB) support to the lfx-v2-project-service Helm chart, allowing operators to configure disruption budgets to maintain availability during voluntary disruptions like node drains or cluster upgrades. The feature is disabled by default.

Changes:

  • Adds a new pdb.yaml Helm template that conditionally creates a PodDisruptionBudget resource with configurable minAvailable and maxUnavailable settings
  • Adds podDisruptionBudget configuration values to values.yaml (disabled by default)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
charts/lfx-v2-project-service/templates/pdb.yaml New template that creates a PodDisruptionBudget when enabled, using the same app: {{ .Chart.Name }} selector as the Deployment
charts/lfx-v2-project-service/values.yaml Adds podDisruptionBudget section with enabled, minAvailable, and maxUnavailable options

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to +28
podDisruptionBudget:
enabled: false
# minAvailable: 1
# maxUnavailable: 1
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The podDisruptionBudget section is missing the descriptive comment above it that every other top-level section in this file has (e.g., # image is the configuration for the container images, # replicaCount is the number of replicas for the deployment, # resources is the configuration for container resource limits and requests). Please add a comment like # podDisruptionBudget is the configuration for the PodDisruptionBudget resource to stay consistent with the rest of the file.

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +19
{{- if .Values.podDisruptionBudget.enabled }}
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ .Chart.Name }}
namespace: {{ .Release.Namespace }}
spec:
selector:
matchLabels:
app: {{ .Chart.Name }}
{{- with .Values.podDisruptionBudget.minAvailable }}
minAvailable: {{ . }}
{{- end }}
{{- with .Values.podDisruptionBudget.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

If podDisruptionBudget.enabled is true but neither minAvailable nor maxUnavailable is specified, this template will create a PDB with no disruption constraint — effectively allowing all pods to be disrupted simultaneously. This is a valid Kubernetes resource but almost certainly a misconfiguration. Consider adding a validation check to fail with a helpful error message when the PDB is enabled without either field, for example:

{{- if and .Values.podDisruptionBudget.enabled (not (or .Values.podDisruptionBudget.minAvailable .Values.podDisruptionBudget.maxUnavailable)) }}
{{- fail "podDisruptionBudget.enabled is true but neither minAvailable nor maxUnavailable is set" }}
{{- end }}

Copilot uses AI. Check for mistakes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1166
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
asithade
asithade previously approved these changes Mar 6, 2026
Copy link

@asithade asithade left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@charts/lfx-v2-project-service/templates/pdb.yaml`:
- Around line 3-6: The template currently checks that both minAvailable and
maxUnavailable are not set simultaneously but misses validation that at least
one must be provided when .Values.podDisruptionBudget.enabled is true; update
the pdb.yaml logic (the block using hasKey .Values.podDisruptionBudget
"minAvailable" and hasKey ... "maxUnavailable") to also fail when neither key is
present by adding a condition like if enabled and not hasKey(... "minAvailable")
and not hasKey(... "maxUnavailable") then call fail with a clear message (e.g.,
"podDisruptionBudget: either minAvailable or maxUnavailable must be set when
enabled is true") so the chart enforces one constraint.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 63cb8daf-e182-4e20-abbe-08de1e22892c

📥 Commits

Reviewing files that changed from the base of the PR and between a77df30 and b288696.

📒 Files selected for processing (2)
  • charts/lfx-v2-project-service/templates/pdb.yaml
  • charts/lfx-v2-project-service/values.yaml

Comment on lines +3 to +6
{{- if .Values.podDisruptionBudget.enabled }}
{{- if and (hasKey .Values.podDisruptionBudget "minAvailable") (hasKey .Values.podDisruptionBudget "maxUnavailable") }}
{{- fail "podDisruptionBudget: cannot set both minAvailable and maxUnavailable" }}
{{- end }}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add validation for when neither constraint is specified.

The template validates that both cannot be set, but doesn't validate that at least one must be set. If enabled: true without either minAvailable or maxUnavailable, the resulting PDB will have no constraint and won't provide disruption protection.

🛡️ Proposed fix to add validation
 {{- if .Values.podDisruptionBudget.enabled }}
 {{- if and (hasKey .Values.podDisruptionBudget "minAvailable") (hasKey .Values.podDisruptionBudget "maxUnavailable") }}
   {{- fail "podDisruptionBudget: cannot set both minAvailable and maxUnavailable" }}
 {{- end }}
+{{- if not (or (hasKey .Values.podDisruptionBudget "minAvailable") (hasKey .Values.podDisruptionBudget "maxUnavailable")) }}
+  {{- fail "podDisruptionBudget: must set either minAvailable or maxUnavailable when enabled" }}
+{{- end }}
 ---
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- if .Values.podDisruptionBudget.enabled }}
{{- if and (hasKey .Values.podDisruptionBudget "minAvailable") (hasKey .Values.podDisruptionBudget "maxUnavailable") }}
{{- fail "podDisruptionBudget: cannot set both minAvailable and maxUnavailable" }}
{{- end }}
{{- if .Values.podDisruptionBudget.enabled }}
{{- if and (hasKey .Values.podDisruptionBudget "minAvailable") (hasKey .Values.podDisruptionBudget "maxUnavailable") }}
{{- fail "podDisruptionBudget: cannot set both minAvailable and maxUnavailable" }}
{{- end }}
{{- if not (or (hasKey .Values.podDisruptionBudget "minAvailable") (hasKey .Values.podDisruptionBudget "maxUnavailable")) }}
{{- fail "podDisruptionBudget: must set either minAvailable or maxUnavailable when enabled" }}
{{- end }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/lfx-v2-project-service/templates/pdb.yaml` around lines 3 - 6, The
template currently checks that both minAvailable and maxUnavailable are not set
simultaneously but misses validation that at least one must be provided when
.Values.podDisruptionBudget.enabled is true; update the pdb.yaml logic (the
block using hasKey .Values.podDisruptionBudget "minAvailable" and hasKey ...
"maxUnavailable") to also fail when neither key is present by adding a condition
like if enabled and not hasKey(... "minAvailable") and not hasKey(...
"maxUnavailable") then call fail with a clear message (e.g.,
"podDisruptionBudget: either minAvailable or maxUnavailable must be set when
enabled is true") so the chart enforces one constraint.

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