Skip to content

Commit

Permalink
Merge pull request #600 from ricardomaraschini/bz-1857684-backport-4.4
Browse files Browse the repository at this point in the history
[release-4.4] Bug 1873534: Using last finished job and disabling retries
  • Loading branch information
openshift-merge-robot committed Sep 11, 2020
2 parents 7081ab0 + 870f959 commit 230861f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions pkg/operator/controllerimagepruner.go
Expand Up @@ -183,8 +183,15 @@ func (c *ImagePrunerController) sync() error {

lastPrunerJobConditions := []batchv1.JobCondition{}
if len(prunerJobs) > 0 {
sort.Sort(ByCreationTimestamp(prunerJobs))
lastPrunerJobConditions = prunerJobs[len(prunerJobs)-1].Status.Conditions
sort.Sort(sort.Reverse(ByCreationTimestamp(prunerJobs)))
for _, job := range prunerJobs {
// skip not finished jobs.
if len(job.Status.Conditions) == 0 {
continue
}
lastPrunerJobConditions = job.Status.Conditions
break
}
}

c.syncPrunerStatus(pcr, prunerCronJob, lastPrunerJobConditions)
Expand Down
4 changes: 3 additions & 1 deletion pkg/resource/prunercronjob.go
Expand Up @@ -90,6 +90,7 @@ func (gcj *generatorPrunerCronJob) expected() (runtime.Object, error) {
return nil, err
}

backoffLimit := int32(0)
cj := &batchapi.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: gcj.GetName(),
Expand All @@ -104,9 +105,10 @@ func (gcj *generatorPrunerCronJob) expected() (runtime.Object, error) {
StartingDeadlineSeconds: &defaultStartingDeadlineSeconds,
JobTemplate: batchapi.JobTemplateSpec{
Spec: batchv1.JobSpec{
BackoffLimit: &backoffLimit,
Template: kcorev1.PodTemplateSpec{
Spec: kcorev1.PodSpec{
RestartPolicy: kcorev1.RestartPolicyOnFailure,
RestartPolicy: kcorev1.RestartPolicyNever,
ServiceAccountName: "pruner",
Affinity: gcj.getAffinity(cr),
NodeSelector: gcj.getNodeSelector(cr),
Expand Down

0 comments on commit 230861f

Please sign in to comment.