Skip to content
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

Merged
merged 1 commit into from Mar 5, 2024

Conversation

ivanvc
Copy link
Contributor

@ivanvc ivanvc commented Feb 9, 2024

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?

`kubectl get job` now displays the status for the listed jobs.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Feb 9, 2024
@k8s-ci-robot
Copy link
Contributor

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 /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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 9, 2024
@kannon92
Copy link
Contributor

/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 Feb 10, 2024
@kannon92
Copy link
Contributor

/sig cli
/sig apps
/wg batch

@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/apps Categorizes an issue or PR as relevant to SIG Apps. wg/batch Categorizes an issue or PR as relevant to WG Batch. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Feb 12, 2024
@@ -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"]},
Copy link
Contributor

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

Copy link
Contributor

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 the Complete=True condition
  • Failed - when has the Failed=True condition
  • FailureTarget - when has the FailureTarget=True condition
  • Suspended - when has the Suspended=True condition, and.spec.suspend=true
  • Resuming - when has the Suspended=True condition, but .spec.suspend != true
  • Suspending - when has the .spec.suspend=true, but no Suspended=True condition
  • Terminating - when deletionTimestamp != nil
  • Running - none of the above, potentially maybe when status.startTime != nil (and the we could have Starting when .status.startTime=nil.

WDYT @kannon92 @alculquicondor @soltysh ?

Copy link
Member

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

Copy link
Contributor

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.

Copy link
Contributor

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).

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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

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)

Copy link
Contributor

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).

@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 Feb 17, 2024
@ivanvc
Copy link
Contributor Author

ivanvc commented Feb 17, 2024

/test pull-kubernetes-verify

Status: batch.JobStatus{
Succeeded: 0,
Conditions: []batch.JobCondition{
{
Copy link
Contributor

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.

Copy link
Contributor Author

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

Choose a reason for hiding this comment

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

Why is JobFailureTarget Needed?

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@kannon92
Copy link
Contributor

kannon92 commented Mar 1, 2024

Very close. Had some minor items on the tests but I think it LGTM.

/assign @alculquicondor
not sure who needs to look this over on sig-cli side.

@ivanvc ivanvc force-pushed the add-suspend-to-jobs-table branch from 16caa9e to 8854d36 Compare March 1, 2024 19:58
@ivanvc ivanvc requested a review from kannon92 March 1, 2024 19:59
@kannon92
Copy link
Contributor

kannon92 commented Mar 1, 2024

/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 1, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: d2db278a5711a7e79ad84d4439ebc50c02359d88

Copy link
Member

@alculquicondor alculquicondor left a comment

Choose a reason for hiding this comment

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

/approve

@alculquicondor
Copy link
Member

/retitle printers: Add Job status to jobs table.

@k8s-ci-robot k8s-ci-robot changed the title printers: add suspend to jobs table printers: Add Job status to jobs table. Mar 5, 2024
@alculquicondor
Copy link
Member

/retitle printers: Add Job status to jobs table

@k8s-ci-robot k8s-ci-robot changed the title printers: Add Job status to jobs table. printers: Add Job status to jobs table Mar 5, 2024
@alculquicondor
Copy link
Member

/release-note-edit

`kubectl get job` now displays the status for the listed jobs.

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/approve

@soltysh
Copy link
Contributor

soltysh commented Mar 5, 2024

/triage accepted
/priority backlog

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 5, 2024
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 5, 2024
@k8s-ci-robot k8s-ci-robot merged commit a814115 into kubernetes:master Mar 5, 2024
13 of 14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.30 milestone Mar 5, 2024
@ivanvc ivanvc deleted the add-suspend-to-jobs-table branch March 5, 2024 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on. wg/batch Categorizes an issue or PR as relevant to WG Batch.
Projects
Archived in project
Archived in project
Development

Successfully merging this pull request may close these issues.

Jobs should display whether or not they are suspended.
8 participants