fixup! fixup! fixup! fixup! fixup! fixup! fixup! Ensure that jobs run with the controller service account if no service account is specified.

This commit is contained in:
2024-12-20 11:34:18 +00:00
parent 57e7576fe8
commit 70595cd7e0
4 changed files with 22 additions and 6 deletions
+2 -2
View File
@@ -10,9 +10,9 @@ description: |
type: application
version: 0.2.22
version: 0.2.24
appVersion: "0.2.22"
appVersion: "0.2.24"
home: https://github.com/lukaszraczylo/kubernetes-images-sync-operator
+1 -1
View File
@@ -12,7 +12,7 @@ sa:
- ALL
image:
repository: ghcr.io/lukaszraczylo/kubernetes-images-sync-operator
tag: 0.2.22
tag: 0.2.24
resources:
limits:
cpu: 500m
@@ -138,12 +138,27 @@ func (r *ClusterImageReconciler) handleRunningClusterImage(ctx context.Context,
if err != nil {
if errors.IsNotFound(err) {
// Job doesn't exist, set status back to PENDING
clusterImage.Status.Progress = shared.STATUS_PENDING
l.Info("Job not found; assuming it completed successfully", "job", jobName)
if clusterImage.Status.Progress == shared.STATUS_SUCCESS || clusterImage.Status.Progress == shared.STATUS_PRESENT {
// Job completed and status is already SUCCESS or PRESENT
return ctrl.Result{}, nil
}
// If we have retries left, consider retrying
if clusterImage.Status.RetryCount < 3 {
clusterImage.Status.Progress = shared.STATUS_RETRYING
clusterImage.Status.RetryCount++
} else {
// Exceeded retries; mark as FAILED
clusterImage.Status.Progress = shared.STATUS_FAILED
}
if err := r.Status().Update(ctx, clusterImage); err != nil {
l.Error(err, "unable to update ClusterImage status back to PENDING")
l.Error(err, "unable to update ClusterImage status after job not found")
return ctrl.Result{}, err
}
return ctrl.Result{Requeue: true}, nil
}
l.Error(err, "unable to check for existing job")
+1
View File
@@ -62,6 +62,7 @@ func CreateJob[T any](params JobParams, setupFunc func(T) []string) *batchv1.Job
Annotations: params.Annotations,
},
Spec: batchv1.JobSpec{
TTLSecondsAfterFinished: pointer.Int32(300),
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{