mirror of
https://github.com/mariadb-operator/mariadb-operator.git
synced 2025-07-25 01:28:31 +00:00
Fix reconciliation of SqlJob history limit updates
This commit is contained in:

committed by
Martin Montes

parent
aecf813f45
commit
4788a7e433
@ -235,6 +235,8 @@ func (r *SqlJobReconciler) reconcileCronJob(ctx context.Context, sqlJob *mariadb
|
||||
}
|
||||
|
||||
patch := client.MergeFrom(existingCronJob.DeepCopy())
|
||||
existingCronJob.Spec.FailedJobsHistoryLimit = desiredCronJob.Spec.FailedJobsHistoryLimit
|
||||
existingCronJob.Spec.SuccessfulJobsHistoryLimit = desiredCronJob.Spec.SuccessfulJobsHistoryLimit
|
||||
existingCronJob.Spec.Schedule = desiredCronJob.Spec.Schedule
|
||||
existingCronJob.Spec.Suspend = desiredCronJob.Spec.Suspend
|
||||
existingCronJob.Spec.JobTemplate.Spec.BackoffLimit = desiredCronJob.Spec.JobTemplate.Spec.BackoffLimit
|
||||
|
@ -266,5 +266,24 @@ var _ = Describe("SqlJob", func() {
|
||||
*scheduledSqlJobWithHistoryLimits.Spec.FailedJobsHistoryLimit
|
||||
return isSuccessfulJobHistoryLimitCorrect && isFailedJobHistoryLimitCorrect
|
||||
}, testHighTimeout, testInterval).Should(BeTrue())
|
||||
|
||||
patch := client.MergeFrom(scheduledSqlJobWithHistoryLimits.DeepCopy())
|
||||
scheduledSqlJobWithHistoryLimits.Spec.SuccessfulJobsHistoryLimit = ptr.To[int32](7)
|
||||
scheduledSqlJobWithHistoryLimits.Spec.FailedJobsHistoryLimit = ptr.To[int32](7)
|
||||
By("Updating a scheduled SqlJob's history limits")
|
||||
Expect(k8sClient.Patch(testCtx, scheduledSqlJobWithHistoryLimits, patch)).To(Succeed())
|
||||
|
||||
By("Expecting to update the CronJob history limits eventually")
|
||||
Eventually(func() bool {
|
||||
var cronJob batchv1.CronJob
|
||||
if k8sClient.Get(testCtx, client.ObjectKeyFromObject(scheduledSqlJobWithHistoryLimits), &cronJob) != nil {
|
||||
return false
|
||||
}
|
||||
isSuccessfulJobHistoryLimitCorrect := *cronJob.Spec.SuccessfulJobsHistoryLimit ==
|
||||
*scheduledSqlJobWithHistoryLimits.Spec.SuccessfulJobsHistoryLimit
|
||||
isFailedJobHistoryLimitCorrect := *cronJob.Spec.FailedJobsHistoryLimit ==
|
||||
*scheduledSqlJobWithHistoryLimits.Spec.FailedJobsHistoryLimit
|
||||
return isSuccessfulJobHistoryLimitCorrect && isFailedJobHistoryLimitCorrect
|
||||
}, testHighTimeout, testInterval).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user