Skip to content

Commit e58da6e

Browse files
committed
fixed build containers for backup job
1 parent c26a614 commit e58da6e

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

pkg/controller/redisclusterbackup/redisclusterbackup_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
8383
},
8484
CreateFunc: func(e event.CreateEvent) bool {
8585
job := e.Object.(*batch.Job)
86-
if job.Status.Succeeded > 0 || job.Status.Failed > utils.Int32(job.Spec.BackoffLimit) {
86+
if job.Status.Succeeded > 0 || job.Status.Failed >= utils.Int32(job.Spec.BackoffLimit) {
8787
return true
8888
}
8989
return false

pkg/controller/redisclusterbackup/sync_handler.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,19 +281,11 @@ func (r *ReconcileRedisClusterBackup) getBackupJob(reqLogger logr.Logger, backup
281281
},
282282
}
283283
if backup.Spec.Backend.Local != nil {
284-
job.Spec.Template.Spec.Containers[0].VolumeMounts = append(job.Spec.Template.Spec.Containers[0].VolumeMounts, corev1.VolumeMount{
285-
Name: "local",
286-
MountPath: backup.Spec.Backend.Local.MountPath,
287-
SubPath: backup.Spec.Backend.Local.SubPath,
288-
})
289284
job.Spec.Template.Spec.Volumes = append(job.Spec.Template.Spec.Volumes, corev1.Volume{
290285
Name: "local",
291286
VolumeSource: backup.Spec.Backend.Local.VolumeSource,
292287
})
293288
}
294-
if cluster.Spec.PasswordSecret != nil {
295-
job.Spec.Template.Spec.Containers[0].Env = append(job.Spec.Template.Spec.Containers[0].Env, redisPassword(cluster))
296-
}
297289

298290
return job, nil
299291
}
@@ -352,6 +344,16 @@ func (r *ReconcileRedisClusterBackup) backupContainers(backup *redisv1alpha1.Red
352344
},
353345
},
354346
}
347+
if cluster.Spec.PasswordSecret != nil {
348+
container.Env = append(container.Env, redisPassword(cluster))
349+
}
350+
if backup.Spec.Backend.Local != nil {
351+
container.VolumeMounts = append(container.VolumeMounts, corev1.VolumeMount{
352+
Name: "local",
353+
MountPath: backup.Spec.Backend.Local.MountPath,
354+
SubPath: backup.Spec.Backend.Local.SubPath,
355+
})
356+
}
355357
containers[i] = container
356358
i++
357359
}
@@ -452,7 +454,7 @@ func (r *ReconcileRedisClusterBackup) handleBackupJob(reqLogger logr.Logger, bac
452454
}
453455
return err
454456
}
455-
if job.Status.Succeeded == 0 && job.Status.Failed <= utils.Int32(job.Spec.BackoffLimit) {
457+
if job.Status.Succeeded == 0 && job.Status.Failed < utils.Int32(job.Spec.BackoffLimit) {
456458
return fmt.Errorf("wait for job Succeeded or Failed")
457459
}
458460

0 commit comments

Comments
 (0)