Skip to content

feat: Update sandbox status with phase#121

Closed
barney-s wants to merge 1 commit intokubernetes-sigs:mainfrom
barney-s:issue-119-fixes
Closed

feat: Update sandbox status with phase#121
barney-s wants to merge 1 commit intokubernetes-sigs:mainfrom
barney-s:issue-119-fixes

Conversation

@barney-s
Copy link
Copy Markdown
Contributor

Adds a 'Phase' field to the 'SandboxStatus' to provide a more explicit status representation of the sandbox.

The phase can be one of 'Pending', 'Running', 'Paused', 'Terminating', or 'Failed'.

This addresses issue #119.

@netlify
Copy link
Copy Markdown

netlify bot commented Oct 27, 2025

Deploy Preview for agent-sandbox canceled.

Name Link
🔨 Latest commit e8124f2
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/698e69505ad63b0008b198c8

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 27, 2025
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 27, 2025
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 27, 2025
@barney-s barney-s force-pushed the issue-119-fixes branch 2 times, most recently from 7f541c2 to 84ed9ec Compare October 27, 2025 23:04
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 28, 2025
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 28, 2025
@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Oct 28, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Oct 28, 2025
@barney-s barney-s force-pushed the issue-119-fixes branch 3 times, most recently from 50a76b7 to b3dd8d6 Compare October 28, 2025 15:27
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 28, 2025
@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 28, 2025
@hzxuzhonghu
Copy link
Copy Markdown
Member

@justinsb can you approve, we want to use this explicit status

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 26, 2025
Adds a 'Phase' field to the 'SandboxStatus' to provide a more explicit
status representation of the sandbox.

The phase can be one of 'Pending', 'Running', 'Paused', 'Terminating', or
'Failed'.

This addresses issue kubernetes-sigs#119.
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 12, 2026
Copy link
Copy Markdown
Contributor

@igooch igooch left a comment

Choose a reason for hiding this comment

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

lgtm

// If the sandbox is being deleted, do nothing
if !sandbox.ObjectMeta.DeletionTimestamp.IsZero() {
log.Info("Sandbox is being deleted")
//sandbox.Status.Phase = sandboxv1alpha1.SandboxPhaseTerminating
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: is this comment intended ?

@vicentefb
Copy link
Copy Markdown
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 13, 2026
Copy link
Copy Markdown
Member

@janetkuo janetkuo left a comment

Choose a reason for hiding this comment

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

There's a violation of K8s API convention.

// Terminating: The Sandbox is terminating.
//
// +optional
Phase SandboxPhase `json:"phase,omitempty"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Using phase is a violation of K8s API convention. From https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties:

The pattern of using phase is deprecated. Newer API types should use conditions instead. Phase was essentially a state-machine enumeration field, that contradicted system-design principles and hampered evolution, since adding new enum values breaks backward compatibility. Rather than encouraging clients to infer implicit properties from phases, we prefer to explicitly expose the individual conditions that clients need to monitor. Conditions also have the benefit that it is possible to create some conditions with uniform meaning across all resource types, while still exposing others that are unique to specific resource types. See #7856 for more details and discussion.

Clients need to monitor the individual conditions that the controller exposes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you propose one condition per phase with true/false ? Or a single condition that is always true but reason is the phase.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That would be just a phase with a different field name. We need to avoid the anti-pattern of using enum, i.e. clients must know all possible reasons to understand the state. Also, condition status needs to be true/false/unknown.
Conditions should describe what's true about the sandbox at a given time, and they can have overlapping states.

For example, we should have these conditions (some from standard conditions): Initialized, Ready, Expired, Terminating.

Paused/Failed should be represented by Ready by setting it to false with appropriate Reason and Message.

Copy link
Copy Markdown
Contributor

@SHRUTI6991 SHRUTI6991 Feb 25, 2026

Choose a reason for hiding this comment

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

As part of the Suspend and resume operation, we want to include very clear condition on when the Sandbox is being Suspended.
We can have a suspended condition with status True or False.

More details on the lifecycle of the condition during a suspend and resume operation: Design.

if err := r.Delete(ctx, sandbox); err != nil && !k8serrors.IsNotFound(err) {
allErrors = errors.Join(allErrors, fmt.Errorf("failed to delete sandbox: %w", err))
} else {
sandbox.Status.Phase = sandboxv1alpha1.SandboxPhaseTerminating
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This only changes the in-memory sandbox. Will this sandbox status be updated?

@vicentefb
Copy link
Copy Markdown
Member

/assign @janetkuo

// Terminating: The Sandbox is terminating.
//
// +optional
Phase SandboxPhase `json:"phase,omitempty"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That would be just a phase with a different field name. We need to avoid the anti-pattern of using enum, i.e. clients must know all possible reasons to understand the state. Also, condition status needs to be true/false/unknown.
Conditions should describe what's true about the sandbox at a given time, and they can have overlapping states.

For example, we should have these conditions (some from standard conditions): Initialized, Ready, Expired, Terminating.

Paused/Failed should be represented by Ready by setting it to false with appropriate Reason and Message.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: barney-s, hzxuzhonghu, igooch
Once this PR has been reviewed and has the lgtm label, please ask for approval from janetkuo. For more information see the Code Review Process.

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

Details 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

@janetkuo janetkuo removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 2, 2026
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 19, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

PR needs rebase.

Details

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
Copy link
Copy Markdown
Contributor

@barney-s: The following tests 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 e8124f2 link true /test presubmit-agent-sandbox-e2e-test
presubmit-agent-sandbox-lint-api e8124f2 link true /test presubmit-agent-sandbox-lint-api

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.

Details

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.

@aditya-shantanu
Copy link
Copy Markdown
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 31, 2026
@igooch
Copy link
Copy Markdown
Contributor

igooch commented Mar 31, 2026

Can this be closed in favor of #422?

@aditya-shantanu
Copy link
Copy Markdown
Contributor

+1. #422 is the latest one.

We should close this one.
This is an old inactive pr.

/close

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@aditya-shantanu: Closed this PR.

Details

In response to this:

+1. #422 is the latest one.

We should close this one.
This is an old inactive pr.

/close

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.

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants