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
WIP: Job: calculate the job completion before calculating the activeDeadlineSeconds #121863
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2089,6 +2089,35 @@ func TestSyncJobPastDeadline(t *testing.T) { | |
expectedCondition: batch.JobSuspended, | ||
expectedConditionReason: "JobSuspended", | ||
}, | ||
"nonIndexed job succeeded and exceeded activeDeadlineSeconds": { | ||
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. For these test cases, do they reproduce the bug if this code is removed? 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. Yes, we can reproduce issues like the following: $ go test -run "TestSyncJobPastDeadline" ./pkg/controller/job/...
? k8s.io/kubernetes/pkg/controller/job/config [no test files]
? k8s.io/kubernetes/pkg/controller/job/config/v1alpha1 [no test files]
? k8s.io/kubernetes/pkg/controller/job/metrics [no test files]
--- FAIL: TestSyncJobPastDeadline (0.00s)
--- FAIL: TestSyncJobPastDeadline/nonIndexed_job_succeeded_and_exceeded_activeDeadlineSeconds (0.00s)
job_controller_test.go:2094: Expected fail condition. Got []v1.JobCondition{v1.JobCondition{Type:"Failed", Status:"True", LastProbeTime:time.Date(2023, time.November, 14, 13, 40, 12, 766800000, time.Local), LastTransitionTime:time.Date(2023, time.November, 14, 13, 40, 12, 766800000, time.Local), Reason:"DeadlineExceeded", Message:"Job was active longer than specified deadline"}}
--- FAIL: TestSyncJobPastDeadline/indexed_job_succeeded_and_exceeded_activeDeadlineSeconds (0.00s)
job_controller_test.go:2094: Expected fail condition. Got []v1.JobCondition{v1.JobCondition{Type:"Failed", Status:"True", LastProbeTime:time.Date(2023, time.November, 14, 13, 40, 12, 767083000, time.Local), LastTransitionTime:time.Date(2023, time.November, 14, 13, 40, 12, 767083000, time.Local), Reason:"DeadlineExceeded", Message:"Job was active longer than specified deadline"}}
FAIL
FAIL k8s.io/kubernetes/pkg/controller/job 0.817s
FAIL 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. Sounds good. |
||
parallelism: 1, | ||
activeDeadlineSeconds: 10, | ||
startTime: 15, | ||
succeededPods: 1, | ||
expectedSucceeded: 1, | ||
expectedCondition: batch.JobComplete, | ||
}, | ||
"indexed job succeeded and exceeded activeDeadlineSeconds": { | ||
parallelism: 2, | ||
completions: 2, | ||
activeDeadlineSeconds: 10, | ||
startTime: 15, | ||
succeededPods: 2, | ||
expectedSucceeded: 2, | ||
expectedCondition: batch.JobComplete, | ||
}, | ||
"elasticIndexed job is scaled down and exceeded activeDeadlineSeconds; the number of succeeded pods already reached the completions": { | ||
parallelism: 1, | ||
completions: 1, | ||
activeDeadlineSeconds: 10, | ||
startTime: 15, | ||
succeededPods: 1, | ||
activePods: 2, | ||
expectedFailed: 2, | ||
expectedSucceeded: 1, | ||
expectedDeletions: 2, | ||
expectedCondition: batch.JobComplete, | ||
}, | ||
} | ||
|
||
for name, tc := range testCases { | ||
|
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 we need this
if
? Maybe, if needed, it could be inside thewantActivePods
function?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 we should put this
if
here sincewantActivePods
is also called in L1478.@mimowo WDYT?
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 Friendly ping :)
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 question is motivated by the fact that this two code paths could result setting different values for
wantActive
. So for example ifsatisfiedExpectations == false
,feature.DefaultFeatureGate.Enabled(features.ElasticIndexedJob)==true
, andjob.Deletion==nil
you will havewantActive=active
here, butwantActive = wantActivePods(&job, jobCtx)
inside manageJob.I'm wondering if we can / should avoid it. No specific failure scenario at the moment.
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.
Ah, you're right. We should call inside
wantActive()
if we need thisif
. Thanks!