-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
describer: improve job and pod template output #122618
describer: improve job and pod template output #122618
Conversation
|
Welcome @ivanvc! |
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 |
2106366
to
243b6fc
Compare
243b6fc
to
c8fa972
Compare
c8fa972
to
ff888ee
Compare
/lgtm |
LGTM label has been added. Git tree hash: dda7e67465193879ad1d0d5caeefaf7c53ddb025
|
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.
Thanks. LGTM overall, suggesting to print out other missing, important GA fields: BackoffLimit
and TTLSecondsAfterFinished
.
We also have a bunch of Beta-level fields in Job (such as PodFailurePolicy
, BackoffLimitPerIndex
, or PodReplacementPolicy
), but I think it is ok to put them in a follow-up PR/Issue to make the distinction (or just wait for GA-level and print as they graduate).
@@ -2516,8 +2519,8 @@ func TestDescribeDeployment(t *testing.T) { | |||
expects: []string{ | |||
"Replicas: 2 desired | 1 updated | 3 total | 2 available | 1 unavailable", | |||
"Image: mytest-image:v2.0", | |||
"OldReplicaSets: bar-001 (2/2 replicas created)", | |||
"NewReplicaSet: bar-002 (1/1 replicas created)", | |||
"OldReplicaSets: bar-001 (2/2 replicas created)", |
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.
nit: revert unrelated formatting changes
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.
When updating the above, please make sure to also address this one.
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.
Hey @mimowo, the tests fail if I don't add the extra spaces here. I think it's due to the alignment of tabs with Node-Selectors
. See:
--- FAIL: TestDescribeDeployment (0.00s)
--- FAIL: TestDescribeDeployment/deployment_during_the_process_of_rolling_out (0.00s)
describe_test.go:2839: expected to find "OldReplicaSets: bar-001 (2/2 replicas created)" in:
Name: bar
Namespace: foo
CreationTimestamp: Fri, 01 Jan 2021 00:00:00 +0000
Labels: k8s-app=bar
Annotations: <none>
Selector: k8s-app=bar
Replicas: 2 desired | 1 updated | 3 total | 2 available | 1 unavailable
StrategyType:
MinReadySeconds: 0
Pod Template:
Labels: k8s-app=bar
Containers:
:
Image: mytest-image:v2.0
Port: <none>
Host Port: <none>
Environment: <none>
Mounts:
/tmp/vol-bar from vol-bar (rw)
/tmp/vol-foo from vol-foo (rw)
Volumes:
vol-foo:
Type: EmptyDir (a temporary directory that shares a pod's lifetime)
Medium:
SizeLimit: <unset>
vol-bar:
Type: EmptyDir (a temporary directory that shares a pod's lifetime)
Medium:
SizeLimit: <unset>
Node-Selectors: <none>
Tolerations: <none>
OldReplicaSets: bar-001 (2/2 replicas created)
NewReplicaSet: bar-002 (1/1 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 12m (x3 over 20m) deployment-controller Scaled up replica set bar-002 to 1
Normal ScalingReplicaSet 10m deployment-controller Scaled up replica set bar-001 to 2
Normal ScalingReplicaSet 2m deployment-controller Scaled up replica set bar-002 to 1
Normal ScalingReplicaSet 60s deployment-controller Scaled down replica set bar-002 to 1
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 see, indeed the values for Node-Selectors
Tolerations
and OldReplicaSets
are aligned in the full output.
Out of curiosity, I'm wondering where is the code / mechanism which determines the shift of OldReplicaSets
to align it. Can you find it out? So that we better understand the intent, because some values are out of alignment, for example Volumes.vol-foo.Type
.
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.
This is the code for the empty dir volume: https://github.com/kubernetes/kubernetes/blob/d2b16b2/staging/src/k8s.io/kubectl/pkg/describe/describe.go#L1028-L1039
From reading the code, the value should be aligned, as it seems just a tab. This is the code for OldReplicaSets
: https://github.com/kubernetes/kubernetes/blob/d2b16b2/staging/src/k8s.io/kubectl/pkg/describe/describe.go#L4372-L4375
@@ -2313,6 +2315,9 @@ func describeJob(job *batchv1.Job, events *corev1.EventList) (string, error) { | |||
if job.Spec.Parallelism != nil { | |||
w.Write(LEVEL_0, "Parallelism:\t%d\n", *job.Spec.Parallelism) | |||
} | |||
if job.Spec.Suspend != nil { |
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.
Can we also print: BackoffLimit
and TTLSecondsAfterFinished
? These are other important GA-level fields. There is also ManualSelector
, but I'm not sure it is relevant enough.
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'd advice against manualSelector, this should be used very cautiously and rarely. The other two are ok addition.
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.
My biggest concern is you're adding this between two important parameters, parallelism and completions, which I frequently look at together. I'd suggest to move suspend printing below completion mode or before parallelism, iow:
your current output looks like:
Annotations: <none>
Parallelism: 1
Suspend: false
Completions: 1
Completion Mode: NonIndexed
Start Time: Mon, 11 Dec 2023 15:18:09 +0100
but I'd suggest to have (suspend before parallelism):
Annotations: <none>
Suspend: false
Parallelism: 1
Completions: 1
Completion Mode: NonIndexed
Start Time: Mon, 11 Dec 2023 15:18:09 +0100
or (suspend after completion mode)
Annotations: <none>
Parallelism: 1
Completions: 1
Completion Mode: NonIndexed
Suspend: false
Start Time: Mon, 11 Dec 2023 15:18:09 +0100
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.
@soltysh, any suggestion on where to place BackoffLimit
and TTLSecondsAfterFinished
? I'm assuming, going with your last suggestion, after Suspend
and before Start Time.
But I just wanted to check if you have an opinion here.
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.
For me pretty much every configuration works, just don't split the Parallelism
, completions
and completionMode
, as pointed out.
If I were to suggest something then maybe:
Annotations: batch.kubernetes.io/cronjob-scheduled-timestamp: 2024-01-19T08:48:00Z
Controlled By: CronJob/hello
Parallelism: 1
Completions: 1
Completion Mode: NonIndexed
**Backoff Limit:** 6
**TTL Seconds After Finished**: 21 # seems reasonable to be close to `Completed At`
Start Time: Fri, 19 Jan 2024 09:48:00 +0100
Completed At: Fri, 19 Jan 2024 09:48:13 +0100
Duration: 13s
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, it now looks like the following:
Name: bar
Namespace: foo
Selector:
Labels: <none>
Annotations: <none>
Completions: <unset>
Suspend: true
Backoff Limit: 1
TTL Seconds After Finished: 123
Pods Statuses: 0 Active / 0 Succeeded / 0 Failed
Pod Template:
Labels: <none>
Containers: <none>
Volumes: <none>
Node-Selectors: <none>
Tolerations: <none>
Events: <none>
If these values are not specified, it omits them:
Name: bar
Namespace: foo
Selector:
Labels: <none>
Annotations: <none>
Completions: <unset>
Pods Statuses: 0 Active / 0 Succeeded / 0 Failed
Pod Template:
Labels: <none>
Containers: <none>
Volumes: <none>
Node-Selectors: <none>
Tolerations: <none>
Events: <none>
/triage accepted |
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.
@ivanvc once you address the comments pls ping me on slack
@@ -2313,6 +2315,9 @@ func describeJob(job *batchv1.Job, events *corev1.EventList) (string, error) { | |||
if job.Spec.Parallelism != nil { | |||
w.Write(LEVEL_0, "Parallelism:\t%d\n", *job.Spec.Parallelism) | |||
} | |||
if job.Spec.Suspend != nil { |
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'd advice against manualSelector, this should be used very cautiously and rarely. The other two are ok addition.
@@ -2313,6 +2315,9 @@ func describeJob(job *batchv1.Job, events *corev1.EventList) (string, error) { | |||
if job.Spec.Parallelism != nil { | |||
w.Write(LEVEL_0, "Parallelism:\t%d\n", *job.Spec.Parallelism) | |||
} | |||
if job.Spec.Suspend != nil { |
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.
My biggest concern is you're adding this between two important parameters, parallelism and completions, which I frequently look at together. I'd suggest to move suspend printing below completion mode or before parallelism, iow:
your current output looks like:
Annotations: <none>
Parallelism: 1
Suspend: false
Completions: 1
Completion Mode: NonIndexed
Start Time: Mon, 11 Dec 2023 15:18:09 +0100
but I'd suggest to have (suspend before parallelism):
Annotations: <none>
Suspend: false
Parallelism: 1
Completions: 1
Completion Mode: NonIndexed
Start Time: Mon, 11 Dec 2023 15:18:09 +0100
or (suspend after completion mode)
Annotations: <none>
Parallelism: 1
Completions: 1
Completion Mode: NonIndexed
Suspend: false
Start Time: Mon, 11 Dec 2023 15:18:09 +0100
@@ -2516,8 +2519,8 @@ func TestDescribeDeployment(t *testing.T) { | |||
expects: []string{ | |||
"Replicas: 2 desired | 1 updated | 3 total | 2 available | 1 unavailable", | |||
"Image: mytest-image:v2.0", | |||
"OldReplicaSets: bar-001 (2/2 replicas created)", | |||
"NewReplicaSet: bar-002 (1/1 replicas created)", | |||
"OldReplicaSets: bar-001 (2/2 replicas created)", |
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.
When updating the above, please make sure to also address this one.
* Add Node-Selectors and Tolerations to pod template's describe output. * Add Suspend, BackoffLimit and TTLSecondsAfterFinished to job's describe output.
ff888ee
to
6d65c06
Compare
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.
/lgtm
/approve
LGTM label has been added. Git tree hash: 1373f785369cdb636b42ae78fe448f7f99f66b99
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 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 |
The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass. This bot retests PRs for certain kubernetes repos according to the following rules:
You can:
/retest |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #122613
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: