feat(agent): add optional PodDisruptionBudget to Agent CRD - #2393
Open
anthonyhaussman wants to merge 2 commits into
Open
feat(agent): add optional PodDisruptionBudget to Agent CRD#2393anthonyhaussman wants to merge 2 commits into
anthonyhaussman wants to merge 2 commits into
Conversation
New podDisruptionBudget field on SharedDeploymentSpec, so Declarative, BYO and SandboxAgent inherit it. Presence of the block enables the budget; removing it prunes the object. The policy API group is not covered by the core/apps/batch/gateway wildcards in the writer and getter roles, so both need an explicit poddisruptionbudgets grant or the controller cannot manage one. MutateFuncFor needs a dedicated case rather than the mergo fallback: minAvailable and maxUnavailable are mutually exclusive, and mergo cannot unset the field being switched away from, which leaves a spec the API server rejects for setting both. Assisted-by: Claude Opus 5 Signed-off-by: Anthony Hausman <ahausman@tf1.fr>
anthonyhaussman
marked this pull request as ready for review
August 4, 2026 17:58
…gent-poddisruptionbudget Signed-off-by: Anthony Hausman <ahausman@tf1.fr> # Conflicts: # go/core/internal/controller/translator/agent/deployments.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an optional
podDisruptionBudgettoSharedDeploymentSpec, soDeclarative,BYO, andSandboxAgentall inherit it.Presence of the block enables the budget. Removing it prunes the object rather than orphaning it, which is why
policyv1.PodDisruptionBudgetis registered unconditionally inGetOwnedResourceTypes(that list drives the prune pass, not just the watches).No effect in Sandbox workload mode, where no Deployment is created.
Two things worth reviewer attention
1. The
policyAPI group needed an explicit RBAC grantThe writer and getter roles wildcard
"",apps,batch, andgateway.networking.k8s.io. None of those coverpolicy, so without the new blocks inwriter-role.yamlandgetter-role.yamlthe controller could not have created the budget at all.2.
MutateFuncForneeded a dedicated case, not the mergo fallbackminAvailableandmaxUnavailableare mutually exclusive and the API server rejects a spec setting both. The genericmergeWithOverridepath cannot express the transition: mergo only writes keys present in the desired object, so the field being switched away from survives and the update fails.This was verified rather than assumed. Removing the new
casemakes three tests inmutate_test.gofail.Validation
CEL enforces the XOR at admission time, mirroring the existing
serviceAccountName/serviceAccountConfigmarker on the same struct:Testing
pod_disruption_budget_test.go: 9 translator tests covering both resolve paths, omission, percentage thresholds, eviction policy, owned-type registration, and no aliasing of the agent specmutate_test.go: 5 tests, 3 of which fail without the new mutate casemake -C go lint: 0 issuesmake controller-manifestsis idempotent, somanifests-checkpassesThe strongest assertion is that the budget selector deep-equals the Deployment selector. A PDB whose selector does not match protects nothing while still looking correct in
kubectl get pdb.