feat: Update sandbox status with phase#121
feat: Update sandbox status with phase#121barney-s wants to merge 1 commit intokubernetes-sigs:mainfrom
Conversation
✅ Deploy Preview for agent-sandbox canceled.
|
c175169 to
f1024c1
Compare
7f541c2 to
84ed9ec
Compare
84ed9ec to
cb934d6
Compare
cb934d6 to
5429888
Compare
5429888 to
75760ac
Compare
75760ac to
7b3914d
Compare
50a76b7 to
b3dd8d6
Compare
b3dd8d6 to
ddd4ea8
Compare
|
@justinsb can you approve, we want to use this explicit status |
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.
84ed9ec to
e8124f2
Compare
| // If the sandbox is being deleted, do nothing | ||
| if !sandbox.ObjectMeta.DeletionTimestamp.IsZero() { | ||
| log.Info("Sandbox is being deleted") | ||
| //sandbox.Status.Phase = sandboxv1alpha1.SandboxPhaseTerminating |
There was a problem hiding this comment.
nit: is this comment intended ?
|
/lgtm |
janetkuo
left a comment
There was a problem hiding this comment.
There's a violation of K8s API convention.
| // Terminating: The Sandbox is terminating. | ||
| // | ||
| // +optional | ||
| Phase SandboxPhase `json:"phase,omitempty"` |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Do you propose one condition per phase with true/false ? Or a single condition that is always true but reason is the phase.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
This only changes the in-memory sandbox. Will this sandbox status be updated?
|
/assign @janetkuo |
| // Terminating: The Sandbox is terminating. | ||
| // | ||
| // +optional | ||
| Phase SandboxPhase `json:"phase,omitempty"` |
There was a problem hiding this comment.
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.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: barney-s, hzxuzhonghu, igooch The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
PR needs rebase. DetailsInstructions 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. |
|
@barney-s: The following tests failed, say
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. DetailsInstructions 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. |
|
/lgtm |
|
Can this be closed in favor of #422? |
|
+1. #422 is the latest one. We should close this one. /close |
|
@aditya-shantanu: Closed this PR. DetailsIn response to this:
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. |
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.