Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
d80ed537
Unverified
Commit
d80ed537
authored
Jun 05, 2018
by
Maciej Szulik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rate limit only when an actual error happens, not on update conflicts
parent
de622012
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
job_controller.go
pkg/controller/job/job_controller.go
+21
-2
job_controller_test.go
pkg/controller/job/job_controller_test.go
+2
-2
job.go
test/e2e/apps/job.go
+7
-1
No files found.
pkg/controller/job/job_controller.go
View file @
d80ed537
...
@@ -48,6 +48,8 @@ import (
...
@@ -48,6 +48,8 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
)
)
const
statusUpdateRetries
=
3
// controllerKind contains the schema.GroupVersionKind for this controller type.
// controllerKind contains the schema.GroupVersionKind for this controller type.
var
controllerKind
=
batch
.
SchemeGroupVersion
.
WithKind
(
"Job"
)
var
controllerKind
=
batch
.
SchemeGroupVersion
.
WithKind
(
"Job"
)
...
@@ -495,7 +497,11 @@ func (jm *JobController) syncJob(key string) (bool, error) {
...
@@ -495,7 +497,11 @@ func (jm *JobController) syncJob(key string) (bool, error) {
var
failureMessage
string
var
failureMessage
string
jobHaveNewFailure
:=
failed
>
job
.
Status
.
Failed
jobHaveNewFailure
:=
failed
>
job
.
Status
.
Failed
exceedsBackoffLimit
:=
jobHaveNewFailure
&&
(
int32
(
previousRetry
)
+
1
>
*
job
.
Spec
.
BackoffLimit
)
// new failures happen when status does not reflect the failures and active
// is different than parallelism, otherwise the previous controller loop
// failed updating status so even if we pick up failure it is not a new one
exceedsBackoffLimit
:=
jobHaveNewFailure
&&
(
active
!=
*
job
.
Spec
.
Parallelism
)
&&
(
int32
(
previousRetry
)
+
1
>
*
job
.
Spec
.
BackoffLimit
)
if
exceedsBackoffLimit
||
pastBackoffLimitOnFailure
(
&
job
,
pods
)
{
if
exceedsBackoffLimit
||
pastBackoffLimitOnFailure
(
&
job
,
pods
)
{
// check if the number of pod restart exceeds backoff (for restart OnFailure only)
// check if the number of pod restart exceeds backoff (for restart OnFailure only)
...
@@ -813,7 +819,20 @@ func (jm *JobController) manageJob(activePods []*v1.Pod, succeeded int32, job *b
...
@@ -813,7 +819,20 @@ func (jm *JobController) manageJob(activePods []*v1.Pod, succeeded int32, job *b
}
}
func
(
jm
*
JobController
)
updateJobStatus
(
job
*
batch
.
Job
)
error
{
func
(
jm
*
JobController
)
updateJobStatus
(
job
*
batch
.
Job
)
error
{
_
,
err
:=
jm
.
kubeClient
.
BatchV1
()
.
Jobs
(
job
.
Namespace
)
.
UpdateStatus
(
job
)
jobClient
:=
jm
.
kubeClient
.
BatchV1
()
.
Jobs
(
job
.
Namespace
)
var
err
error
for
i
:=
0
;
i
<=
statusUpdateRetries
;
i
=
i
+
1
{
var
newJob
*
batch
.
Job
newJob
,
err
=
jobClient
.
Get
(
job
.
Name
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
break
}
newJob
.
Status
=
job
.
Status
if
_
,
err
=
jobClient
.
UpdateStatus
(
newJob
);
err
==
nil
{
break
}
}
return
err
return
err
}
}
...
...
pkg/controller/job/job_controller_test.go
View file @
d80ed537
...
@@ -412,8 +412,8 @@ func TestSyncJobPastDeadline(t *testing.T) {
...
@@ -412,8 +412,8 @@ func TestSyncJobPastDeadline(t *testing.T) {
},
},
"activeDeadlineSeconds with backofflimit reach"
:
{
"activeDeadlineSeconds with backofflimit reach"
:
{
1
,
1
,
1
,
10
,
0
,
1
,
1
,
1
,
10
,
0
,
1
,
0
,
2
,
0
,
0
,
1
,
true
,
1
,
0
,
0
,
3
,
"BackoffLimitExceeded"
,
true
,
0
,
0
,
0
,
1
,
"BackoffLimitExceeded"
,
},
},
}
}
...
...
test/e2e/apps/job.go
View file @
d80ed537
...
@@ -186,7 +186,13 @@ var _ = SIGDescribe("Job", func() {
...
@@ -186,7 +186,13 @@ var _ = SIGDescribe("Job", func() {
By
(
fmt
.
Sprintf
(
"Checking that %d pod created and status is failed"
,
backoff
+
1
))
By
(
fmt
.
Sprintf
(
"Checking that %d pod created and status is failed"
,
backoff
+
1
))
pods
,
err
:=
framework
.
GetJobPods
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
job
.
Name
)
pods
,
err
:=
framework
.
GetJobPods
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
job
.
Name
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
pods
.
Items
)
.
To
(
HaveLen
(
backoff
+
1
))
// Expect(pods.Items).To(HaveLen(backoff + 1))
// due to NumRequeus not being stable enough, especially with failed status
// updates we need to allow more than backoff+1
// TODO revert this back to above when https://github.com/kubernetes/kubernetes/issues/64787 gets fixed
if
len
(
pods
.
Items
)
<
backoff
+
1
{
framework
.
Failf
(
"Not enough pod created expected at least %d, got %#v"
,
backoff
+
1
,
pods
.
Items
)
}
for
_
,
pod
:=
range
pods
.
Items
{
for
_
,
pod
:=
range
pods
.
Items
{
Expect
(
pod
.
Status
.
Phase
)
.
To
(
Equal
(
v1
.
PodFailed
))
Expect
(
pod
.
Status
.
Phase
)
.
To
(
Equal
(
v1
.
PodFailed
))
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment