Skip to content

reconcile: delete statefulset pods when maxUnavailable set to 100%#1815

Open
AndrewChubatiuk wants to merge 2 commits intomasterfrom
statefulset-delete-pods-when-max-unavailable-100
Open

reconcile: delete statefulset pods when maxUnavailable set to 100%#1815
AndrewChubatiuk wants to merge 2 commits intomasterfrom
statefulset-delete-pods-when-max-unavailable-100

Conversation

@AndrewChubatiuk
Copy link
Contributor

@AndrewChubatiuk AndrewChubatiuk commented Feb 18, 2026

fixes #1706


Summary by cubic

Switch StatefulSet rollouts to delete pods when maxUnavailable is 100% for faster, predictable full restarts that aren’t blocked by PDBs. Tests are simplified with controller-runtime client interceptors and testify, removing go-test/deep, and adding coverage for the delete path and PDB behavior.

  • New Features

    • Delete pods instead of evicting during OnDelete StatefulSet updates when maxUnavailable=100% (deletion ignores PDBs); otherwise evict in batches sized by MaxUnavailable.
  • Bug Fixes

    • Treat not-found on delete as success.
    • Ignore terminating pods and non-StatefulSet-owned pods during update checks to avoid false failures.

Written for commit 6eae380. Summary will update on new commits.

@AndrewChubatiuk AndrewChubatiuk changed the title Statefulset delete pods when max unavailable 100 reconcile: delete statefulset pods when maxUnavailable set to 100% Feb 18, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 15 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/controller/operator/factory/reconcile/statefulset.go">

<violation number="1" location="internal/controller/operator/factory/reconcile/statefulset.go:171">
P0: Nil pointer dereference: `cr.UpdateBehavior` can be nil here. The nil guard on line 160 only protects the `GetScaledValueFromIntOrPercent` call, but this new check is outside that guard. When no `UpdateBehavior` is configured (the default), this will panic at runtime.</violation>

<violation number="2" location="internal/controller/operator/factory/reconcile/statefulset.go:373">
P1: Variable shadowing bug: inner `var pod corev1.Pod` (line 373) shadows the outer `var pod *corev1.Pod` (line 371). The outer `pod` remains nil forever, making `podStatusesToError` dead code. On poll timeout, the enriched error diagnostics (pod phase, conditions, container crash states) are silently lost. Change the inner declaration to assign to the outer variable, as the old code did.</violation>
</file>

<file name="docs/CHANGELOG.md">

<violation number="1" location="docs/CHANGELOG.md:31">
P3: Fix the typo "importaint" → "important" in this changelog entry to keep documentation polished.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@AndrewChubatiuk AndrewChubatiuk force-pushed the statefulset-delete-pods-when-max-unavailable-100 branch 3 times, most recently from 74ff139 to 5aa6847 Compare February 18, 2026 12:43
@AndrewChubatiuk AndrewChubatiuk force-pushed the statefulset-delete-pods-when-max-unavailable-100 branch from 5aa6847 to 9ec51c5 Compare February 18, 2026 13:40
@AndrewChubatiuk
Copy link
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Feb 18, 2026

@cubic-dev-ai review this PR

@AndrewChubatiuk I have started the AI code review. It will take a few minutes to complete.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 3 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/CHANGELOG.md">

<violation number="1" location="docs/CHANGELOG.md:31">
P2: Custom agent: **Changelog Review Agent**

The new changelog entry doesn’t follow the required structure: it lacks an explicit before/now user-visible explanation and focuses on implementation details (deletion vs eviction). The Changelog Review Agent rule requires a user-centric before/after description of the impact.</violation>
</file>

<file name="internal/controller/operator/factory/reconcile/statefulset.go">

<violation number="1" location="internal/controller/operator/factory/reconcile/statefulset.go:165">
P2: The delete mode won’t activate for the intended "100%" maxUnavailable because IntValue() returns 0 for percentage strings like "100%". Check the string value/type instead so the 100% case is detected.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@AndrewChubatiuk AndrewChubatiuk force-pushed the statefulset-delete-pods-when-max-unavailable-100 branch 7 times, most recently from 4f3017e to c79bde9 Compare February 18, 2026 23:06
@AndrewChubatiuk
Copy link
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Feb 18, 2026

@cubic-dev-ai review this PR

@AndrewChubatiuk I have started the AI code review. It will take a few minutes to complete.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 7 files

@AndrewChubatiuk AndrewChubatiuk force-pushed the statefulset-delete-pods-when-max-unavailable-100 branch 6 times, most recently from 81fbfd4 to 7c9ca63 Compare February 19, 2026 14:42
@AndrewChubatiuk AndrewChubatiuk force-pushed the statefulset-delete-pods-when-max-unavailable-100 branch from 7c9ca63 to 6eae380 Compare February 19, 2026 18:10
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.

Ignore PodDisruptionBudget during minimal downtime upgrade strategy.

2 participants

Comments