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
k8s-ci-robot
merged 1 commit into
kubernetes:master
from
ivanvc:add-suspend-to-jobs-table
Mar 5, 2024
+145
−14
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2527,8 +2527,8 @@ func TestPrintJob(t *testing.T) { | |
}, | ||
}, | ||
options: printers.GenerateOptions{}, | ||
// Columns: Name, Completions, Duration, Age | ||
expected: []metav1.TableRow{{Cells: []interface{}{"job1", "1/2", "", "0s"}}}, | ||
// Columns: Name, Status, Completions, Duration, Age | ||
expected: []metav1.TableRow{{Cells: []interface{}{"job1", "Running", "1/2", "", "0s"}}}, | ||
}, | ||
// Generate table rows for Job with generate options "Wide". | ||
{ | ||
|
@@ -2560,10 +2560,10 @@ func TestPrintJob(t *testing.T) { | |
}, | ||
}, | ||
options: printers.GenerateOptions{Wide: true}, | ||
// Columns: Name, Completions, Duration, Age, Containers, Images, Selectors | ||
// Columns: Name, Status, Completions, Duration, Age, Containers, Images, Selectors | ||
expected: []metav1.TableRow{ | ||
{ | ||
Cells: []interface{}{"job1", "1/2", "", "0s", "fake-job-container1,fake-job-container2", "fake-job-image1,fake-job-image2", "job-label=job-label-value"}, | ||
Cells: []interface{}{"job1", "Running", "1/2", "", "0s", "fake-job-container1,fake-job-container2", "fake-job-image1,fake-job-image2", "job-label=job-label-value"}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -2582,8 +2582,8 @@ func TestPrintJob(t *testing.T) { | |
}, | ||
}, | ||
options: printers.GenerateOptions{}, | ||
// Columns: Name, Completions, Duration, Age | ||
expected: []metav1.TableRow{{Cells: []interface{}{"job2", "0/1", "", "10y"}}}, | ||
// Columns: Name, Status, Completions, Duration, Age | ||
expected: []metav1.TableRow{{Cells: []interface{}{"job2", "Running", "0/1", "", "10y"}}}, | ||
}, | ||
// Job with duration. | ||
{ | ||
|
@@ -2602,8 +2602,8 @@ func TestPrintJob(t *testing.T) { | |
}, | ||
}, | ||
options: printers.GenerateOptions{}, | ||
// Columns: Name, Completions, Duration, Age | ||
expected: []metav1.TableRow{{Cells: []interface{}{"job3", "0/1", "30m", "10y"}}}, | ||
// Columns: Name, Status, Completions, Duration, Age | ||
expected: []metav1.TableRow{{Cells: []interface{}{"job3", "Running", "0/1", "30m", "10y"}}}, | ||
}, | ||
{ | ||
job: batch.Job{ | ||
|
@@ -2620,8 +2620,115 @@ func TestPrintJob(t *testing.T) { | |
}, | ||
}, | ||
options: printers.GenerateOptions{}, | ||
// Columns: Name, Completions, Duration, Age | ||
expected: []metav1.TableRow{{Cells: []interface{}{"job4", "0/1", "20m", "10y"}}}, | ||
// Columns: Name, Status, Completions, Duration, Age | ||
expected: []metav1.TableRow{{Cells: []interface{}{"job4", "Running", "0/1", "20m", "10y"}}}, | ||
}, | ||
{ | ||
job: batch.Job{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "job5", | ||
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)}, | ||
}, | ||
Spec: batch.JobSpec{ | ||
Completions: nil, | ||
}, | ||
Status: batch.JobStatus{ | ||
Succeeded: 0, | ||
Conditions: []batch.JobCondition{ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
Type: batch.JobComplete, | ||
Status: api.ConditionTrue, | ||
}, | ||
}, | ||
}, | ||
}, | ||
options: printers.GenerateOptions{}, | ||
// Columns: Name, Status, Completions, Duration, Age | ||
expected: []metav1.TableRow{{Cells: []interface{}{"job5", "Complete", "0/1", "", "0s"}}}, | ||
}, | ||
{ | ||
job: batch.Job{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "job6", | ||
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)}, | ||
}, | ||
Spec: batch.JobSpec{ | ||
Completions: nil, | ||
}, | ||
Status: batch.JobStatus{ | ||
Succeeded: 0, | ||
Conditions: []batch.JobCondition{ | ||
{ | ||
Type: batch.JobFailed, | ||
Status: api.ConditionTrue, | ||
}, | ||
}, | ||
}, | ||
}, | ||
options: printers.GenerateOptions{}, | ||
// Columns: Name, Status, Completions, Duration, Age | ||
expected: []metav1.TableRow{{Cells: []interface{}{"job6", "Failed", "0/1", "", "0s"}}}, | ||
}, | ||
{ | ||
job: batch.Job{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "job7", | ||
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)}, | ||
}, | ||
Spec: batch.JobSpec{ | ||
Completions: nil, | ||
}, | ||
Status: batch.JobStatus{ | ||
Succeeded: 0, | ||
Conditions: []batch.JobCondition{ | ||
{ | ||
Type: batch.JobSuspended, | ||
Status: api.ConditionTrue, | ||
}, | ||
}, | ||
}, | ||
}, | ||
options: printers.GenerateOptions{}, | ||
// Columns: Name, Status, Completions, Duration, Age | ||
expected: []metav1.TableRow{{Cells: []interface{}{"job7", "Suspended", "0/1", "", "0s"}}}, | ||
}, | ||
{ | ||
job: batch.Job{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "job8", | ||
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)}, | ||
}, | ||
Spec: batch.JobSpec{ | ||
Completions: nil, | ||
}, | ||
Status: batch.JobStatus{ | ||
Succeeded: 0, | ||
Conditions: []batch.JobCondition{ | ||
{ | ||
Type: batch.JobFailureTarget, | ||
Status: api.ConditionTrue, | ||
}, | ||
}, | ||
}, | ||
}, | ||
options: printers.GenerateOptions{}, | ||
// Columns: Name, Status, Completions, Duration, Age | ||
expected: []metav1.TableRow{{Cells: []interface{}{"job8", "FailureTarget", "0/1", "", "0s"}}}, | ||
}, | ||
{ | ||
job: batch.Job{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "job9", | ||
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)}, | ||
DeletionTimestamp: &metav1.Time{Time: time.Now().Add(1.9e9)}, | ||
}, | ||
Spec: batch.JobSpec{ | ||
Completions: nil, | ||
}, | ||
}, | ||
options: printers.GenerateOptions{}, | ||
// Columns: Name, Status, Completions, Duration, Age | ||
expected: []metav1.TableRow{{Cells: []interface{}{"job9", "Terminating", "0/1", "", "0s"}}}, | ||
}, | ||
} | ||
|
||
|
@@ -2701,10 +2808,10 @@ func TestPrintJobList(t *testing.T) { | |
}, | ||
} | ||
|
||
// Columns: Name, Completions, Duration, Age | ||
// Columns: Name, Status, Completions, Duration, Age | ||
expectedRows := []metav1.TableRow{ | ||
{Cells: []interface{}{"job1", "1/2", "", "0s"}}, | ||
{Cells: []interface{}{"job2", "2/2", "20m", "0s"}}, | ||
{Cells: []interface{}{"job1", "Running", "1/2", "", "0s"}}, | ||
{Cells: []interface{}{"job2", "Running", "2/2", "20m", "0s"}}, | ||
} | ||
|
||
rows, err := printJobList(&jobList, printers.GenerateOptions{}) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 do you think
JobFailureTarget
is useful for a user?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 on a fence here. Terminating pods in reaction to FailJob action might take ~30s between SIGTERM and SIGKILL. Knowing that the job is doomed to be failed might be useful I guess.
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.
Okay. I'm happy with it then.