From 2fb270aa2fd892bb03ecea42f8b4af860f710e74 Mon Sep 17 00:00:00 2001 From: Erik Godding Boye Date: Fri, 24 Mar 2023 12:46:23 +0100 Subject: [PATCH] revert: "fix: never retry scan job (#194)" (#298) --- .../controller/stas/testdata/scan-job/expected-scan-job.yaml | 4 ++-- internal/trivy/scan_job.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/controller/stas/testdata/scan-job/expected-scan-job.yaml b/internal/controller/stas/testdata/scan-job/expected-scan-job.yaml index 46d11d6f..71a13982 100644 --- a/internal/controller/stas/testdata/scan-job/expected-scan-job.yaml +++ b/internal/controller/stas/testdata/scan-job/expected-scan-job.yaml @@ -17,7 +17,7 @@ metadata: name: echo-6bdfc76c56-8ae43-738e6 spec: activeDeadlineSeconds: 3600 # 1 hour - backoffLimit: 0 + backoffLimit: 3 completionMode: NonIndexed completions: 1 parallelism: 1 @@ -117,7 +117,7 @@ spec: volumeMounts: - mountPath: /var/run/image-scanner name: image-scanner - restartPolicy: Never + restartPolicy: OnFailure schedulerName: default-scheduler securityContext: {} serviceAccount: image-scanner diff --git a/internal/trivy/scan_job.go b/internal/trivy/scan_job.go index 8cad0b67..8fe2f231 100644 --- a/internal/trivy/scan_job.go +++ b/internal/trivy/scan_job.go @@ -142,7 +142,7 @@ func (f *filesystemScanJobBuilder) newImageScanJob(spec stasv1alpha1.ContainerIm job.Spec.Parallelism = pointer.Int32(1) job.Spec.Completions = pointer.Int32(1) job.Spec.ActiveDeadlineSeconds = pointer.Int64(int64(3600)) - job.Spec.BackoffLimit = pointer.Int32(0) + job.Spec.BackoffLimit = pointer.Int32(3) job.Spec.TTLSecondsAfterFinished = pointer.Int32(7200) job.Spec.Template.Spec.ServiceAccountName = f.ScanJobServiceAccount @@ -169,7 +169,7 @@ func (f *filesystemScanJobBuilder) newImageScanJob(spec stasv1alpha1.ContainerIm } job.Spec.Template.Spec.AutomountServiceAccountToken = pointer.Bool(false) - job.Spec.Template.Spec.RestartPolicy = corev1.RestartPolicyNever + job.Spec.Template.Spec.RestartPolicy = corev1.RestartPolicyOnFailure return job, nil }