Skip to content

Conversation

@antonipp
Copy link
Contributor

Description

While trying out the agent-sandbox project, I noticed that the main controller is deployed as a StatefulSet. I couldn't really find a justification for it in the commit history, so this looks like an oversight. The controller is stateless and doesn't require a stable network identity, so I don't really see a reason to use a much heavier abstraction here. Moreover, STS ordered rollout semantics are unnecessary for a stateless controller and could complicate scaling/updates if leader election is enabled for HA.

So my PR switches the controller to be deployed as a simple Deployment, I think it will make operations easier for everyone

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: antonipp
Once this PR has been reviewed and has the lgtm label, please assign justinsb for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 27, 2025
@netlify
Copy link

netlify bot commented Nov 27, 2025

Deploy Preview for agent-sandbox canceled.

Name Link
🔨 Latest commit 1571613
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/69302cc49364080008d430ef

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 27, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @antonipp. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 27, 2025
@janetkuo
Copy link
Member

janetkuo commented Dec 2, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 2, 2025
---

kind: StatefulSet
kind: Deployment
Copy link
Member

Choose a reason for hiding this comment

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

To provide some more context, the original discussion regarding StatefulSet vs. Deployment is here: #13 (comment)

Note that if we decide to accept this change, this requires an additional migration step when upgrading Agent Sandbox to this version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah thanks, I didn't see this conversation. But tbh I still don't really understand why an STS would be better for leader election specifically? I don't really see why the overhead would be worth it. (cc @justinsb)

Also FWIW, we've been running dozens of different controllers over the years and from what I've seen they've all been Deployments. When it comes to the identity, they seem to simply be using os.Hostname(). We don't need static STS identities at all.

Random examples:

They just have way less constraints and are easier to operate.

@barney-s
Copy link
Contributor

barney-s commented Dec 2, 2025

This is an acceptable change. We can switch back to sts later if needed. Would you check the docs and check if they need a change.

Copy link
Contributor

@barney-s barney-s left a comment

Choose a reason for hiding this comment

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

Thanks for the changes

labels:
app: agent-sandbox-controller
spec:
serviceName: agent-sandbox-controller
Copy link
Contributor

Choose a reason for hiding this comment

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

While removing serviceName is correct for a Deployment, it's worth double-checking if any other part of the system implicitly relied on the stable pod names generated by the StatefulSet (e.g., in logging, monitoring, or custom scripts).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok actually found 1 reference in examples/jupyterlab/README.md but that's it (and it's good that nothing depended on this logic)

---

kind: StatefulSet
kind: Deployment
Copy link
Contributor

Choose a reason for hiding this comment

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

While changing the kind to Deployment is the correct move for a stateless controller, this is a breaking change for existing users. An upgrade will not be smooth as the new Deployment won't manage the old StatefulSet's pods.

Please add a note to the RELEASE.md or a dedicated upgrade guide explaining the manual steps required, which likely involve deleting the old StatefulSet before applying the new manifests.

Copy link
Contributor Author

@antonipp antonipp Dec 3, 2025

Choose a reason for hiding this comment

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

I am aware it's a breaking change but not really sure what's the actual process for documenting it should be. RELEASE.md feels wrong and an upgrade guide is overkill for such as simple change (especially since the project is in the early days and users should expect the internals to change)

Maybe something we just call out in the Github release notes somehow?

@antonipp antonipp force-pushed the ai/sts-to-deployment branch from aa548c2 to 1571613 Compare December 3, 2025 12:27
@antonipp
Copy link
Contributor Author

antonipp commented Dec 3, 2025

/retest

@k8s-ci-robot
Copy link
Contributor

@antonipp: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
presubmit-agent-sandbox-e2e-test 1571613 link true /test presubmit-agent-sandbox-e2e-test

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants