New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
printers: Add Job status to jobs table #123226
printers: Add Job status to jobs table #123226
Conversation
Hi @ivanvc. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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/test-infra repository. |
/ok-to-test |
/sig cli |
@@ -167,6 +167,7 @@ func AddHandlers(h printers.PrintHandler) { | |||
|
|||
jobColumnDefinitions := []metav1.TableColumnDefinition{ | |||
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]}, | |||
{Name: "Suspend", Type: "boolean", Description: batchv1.JobSpec{}.SwaggerDoc()["suspend"]}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rather prefer Suspended
here as it conveys better the state of the job. I find using the verb Suspend
a bit confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm now leaning more towards the approach as we have for pods where we have the STATUS
column reflecting the current pod state, doing lookup to multiple places: https://github.com/kubernetes/kubernetes/blob/master/pkg/printers/internalversion/printers.go#L834-L959.
The states I can we could have for Job:
Complete
- when has theComplete=True
conditionFailed
- when has theFailed=True
conditionFailureTarget
- when has theFailureTarget=True
conditionSuspended
- when has theSuspended=True
condition, and.spec.suspend=true
Resuming
- when has theSuspended=True
condition, but.spec.suspend != true
Suspending
- when has the.spec.suspend=true
, but noSuspended=True
conditionTerminating
- whendeletionTimestamp != nil
Running
- none of the above, potentially maybe whenstatus.startTime != nil
(and the we could haveStarting
when.status.startTime=nil
.
WDYT @kannon92 @alculquicondor @soltysh ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't make a distinction between suspended, resuming, suspending. I would just use the condition.
Other than that, SGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the change suggested by @mimowo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok either with dropping Resuming
and Suspending
or keeping them.
Regardless, we should set the state based on condition as the actual state, not the spec.suspend (desired state).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you suggest closing this PR, and starting a new one?
Do we have a consensus on keeping or removing Suspending
and Resuming
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally had it as "Suspended", but then I saw that CronJob's suspend is shown as "Suspend",
I see, but here are some differences with CronJob: I don't think CronJob supports conditions, can it be "finished"? I feel since job can be in multiple "states" it makes sense to put them into a single column to avoid creating a column per field or condition. Similarly as for pod.
Do you suggest closing this PR, and starting a new one?
I would suggest updating this one. You can put a new PR so that we don't lose history in case some changes get reverted due to new insights, but I think keeping the PR open is beneficial to also keep discussions in one place, because they would be similar in the new PR.
Do we have a consensus on keeping or removing Suspending and Resuming?
The transient states resuming
and suspending
are very short, so I'm ok either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mimowo, @kaisoz, @kannon92, @alculquicondor PTAL @ #123349 which supersedes this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add commit's to this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I'll close the other one.
@@ -1156,7 +1157,7 @@ func printJob(obj *batch.Job, options printers.GenerateOptions) ([]metav1.TableR | |||
jobDuration = duration.HumanDuration(obj.Status.CompletionTime.Sub(obj.Status.StartTime.Time)) | |||
} | |||
|
|||
row.Cells = append(row.Cells, obj.Name, completions, jobDuration, translateTimestampSince(obj.CreationTimestamp)) | |||
row.Cells = append(row.Cells, obj.Name, printBoolPtr(obj.Spec.Suspend), completions, jobDuration, translateTimestampSince(obj.CreationTimestamp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the column should only show a boolean True
or False
.
printBoolPtr
will print <unset>
in case obj.Spec.Suspend
is nil
. Since a job is not suspended by default I think the column should read False
in such case (<unset>
doesn't tell you the state of the job)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we are going to directly expose the value of the .spec.suspend
field, then probably the 3 values: <unset>
, true
, false
makes sense, but I also think that what the user is mostly interested in is the state of the job, as mentioned here: #123226 (comment).
04559e6
to
9925552
Compare
/test pull-kubernetes-verify |
9925552
to
46ff408
Compare
Status: batch.JobStatus{ | ||
Succeeded: 0, | ||
Conditions: []batch.JobCondition{ | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably include Failed or Complete. Not both. It is a bit confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Succeeded: 0, | ||
Conditions: []batch.JobCondition{ | ||
{ | ||
Type: batch.JobFailureTarget, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is JobFailureTarget Needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to delete it. It's a remaining when the conditions weren't in the current order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Very close. Had some minor items on the tests but I think it LGTM. /assign @alculquicondor |
16caa9e
to
8854d36
Compare
/lgtm |
LGTM label has been added. Git tree hash: d2db278a5711a7e79ad84d4439ebc50c02359d88
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
/retitle printers: Add Job status to jobs table. |
/retitle printers: Add Job status to jobs table |
/release-note-edit
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
/triage accepted |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alculquicondor, ivanvc, soltysh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Adds the suspend column before completions for the Jobs table.
Which issue(s) this PR fixes:
Fixes #123221
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: