support automatic service creation opt-in#775
Conversation
✅ Deploy Preview for agent-sandbox canceled.
|
|
|
d61d0b0 to
19df48f
Compare
There was a problem hiding this comment.
Pull request overview
This PR makes headless Service creation/management by the Sandbox controller opt-in via a new spec.service boolean (default false), aligning behavior with typical Kubernetes patterns and reducing per-Sandbox Service overhead.
Changes:
- Added
spec.service(defaultfalse) to the Sandbox API/CRD to gate automatic headless Service management. - Updated the Sandbox controller to conditionally create/adopt/repair Services only when
spec.service: true, and to delete owned Services when toggled off. - Relaxed Ready condition gating so Service readiness is only required when
spec.service: true.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
api/v1alpha1/sandbox_types.go |
Adds SandboxSpec.Service field with defaulting marker and doc comment. |
controllers/sandbox_controller.go |
Gates Service reconcile and Ready-condition logic on spec.service; clears status when disabled; deletes owned Service when toggled off. |
controllers/sandbox_controller_test.go |
Updates existing tests and adds new cases for the new default (no Service) and for Service deletion/ignoring when disabled. |
k8s/crds/agents.x-k8s.io_sandboxes.yaml |
Adds CRD schema for spec.service with default false. |
helm/crds/agents.x-k8s.io_sandboxes.yaml |
Mirrors CRD schema change for Helm packaging. |
|
Hi @janetkuo @justinsb
Should I: |
91072e6 to
e761d3f
Compare
e761d3f to
1d7047d
Compare
1d7047d to
f098788
Compare
|
/retest |
6e74ff1 to
d887353
Compare
d887353 to
0274558
Compare
|
/ok-to-test |
| // When unset (nil), the controller preserves existing Services for backward | ||
| // compatibility but does not create new ones. Set to true to enable or false | ||
| // to explicitly disable and remove the Service. | ||
| //nolint:kubeapilinter |
There was a problem hiding this comment.
nit: should be // nolint: nobool. We just want to bypass this lint check. The reason should be clearly documented as well.
| //nolint:kubeapilinter | |
| //nolint:nobools // Reason why boolean is used despite the linter rule |
| sandbox.Annotations[v1alpha1.SandboxTemplateRefAnnotation] = template.Name | ||
|
|
||
| template.Spec.PodTemplate.DeepCopyInto(&sandbox.Spec.PodTemplate) | ||
| sandbox.Spec.Service = new(true) |
There was a problem hiding this comment.
SandboxClaim should leverage the new default, instead of keeping the old behavior. Otherwise it will be inconsistent with sandbox.
| }, | ||
| Spec: sandboxv1alpha1.SandboxSpec{ | ||
| Replicas: &replicas, | ||
| Service: new(true), |
There was a problem hiding this comment.
Same comment here regarding adopting the right default.
|
|
||
| // service controls whether the controller should automatically create a | ||
| // headless Service for this Sandbox. | ||
| // When unset (nil), the controller preserves existing Services for backward |
There was a problem hiding this comment.
nit
| // When unset (nil), the controller preserves existing Services for backward | |
| // When unset, the controller preserves existing Services for backward |
because users can't set nil in json/yaml
janetkuo
left a comment
There was a problem hiding this comment.
/lgtm
The review comments can be addressed in a follow-up PR.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aditya-shantanu, flpanbin, janetkuo 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 |
What this PR does / why we need it:
This PR introduces a new
spec.servicefield to make automatic headless Service creation opt-in instead of the default behavior, while preserving backward compatibility for existing Sandboxes.spec.serviceis a*boolso the controller can distinguish three states:unset (nil): default, backward-compatible — preserves existing owned Service but does not create new ones.false: explicitly disables Service management — deletes any existing owned Service.true: explicitly enables Service management — creates or reconciles the headless Service.Which issue(s) this PR is related to:
Fixes #746
Changes:
Added
spec.serviceas*boolwith//nolint:kubeapilinterto bypass the nobools linter rule.Updated
reconcileServiceto conditionally create, adopt, or delete the headless Service based onspec.service.Updated
computeReadyCondition.Added controller tests covering all three states.
Release Note