core: only log errors with v1beta1 cron job
v1beta1 cron jobs have not been created by rook since k8s 1.21
and now are fully removed in 1.25. As long as we still support
older than 1.21 we still need to attempt to delete the v1beta1
cron jobs in case they had been created before an upgrade.
If the deletion fails, now we just log a debug statement since
it is a normal condition, and continue with the v1 cron job
creation.
Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
(cherry picked from commit 538025111a)
This commit is contained in:
1 parent
959df0185d
commit
b39c2827f6
1 file changed
+3
-7
@@ -164,9 +164,7 @@ func (r *ReconcileNode) createOrUpdateCephCron(cephCluster cephv1.CephCluster, c
|
||||
|
||||
// minimum k8s version required for v1 cronJob is 'v1.21.0'. Apply v1 if k8s version is at least 'v1.21.0', else apply v1beta1 cronJob.
|
||||
if useCronJobV1 {
|
||||
if err := r.deletev1betaJob(objectMeta); err != nil {
|
||||
return controllerutil.OperationResultNone, err
|
||||
}
|
||||
r.deletev1betaJob(objectMeta)
|
||||
|
||||
cronJob := &v1.CronJob{ObjectMeta: objectMeta}
|
||||
err := controllerutil.SetControllerReference(&cephCluster, cronJob, r.scheme)
|
||||
@@ -202,18 +200,16 @@ func (r *ReconcileNode) createOrUpdateCephCron(cephCluster cephv1.CephCluster, c
|
||||
return controllerutil.CreateOrUpdate(r.opManagerContext, r.client, cronJob, mutateFunc)
|
||||
}
|
||||
|
||||
func (r *ReconcileNode) deletev1betaJob(objectMeta metav1.ObjectMeta) error {
|
||||
func (r *ReconcileNode) deletev1betaJob(objectMeta metav1.ObjectMeta) {
|
||||
// delete v1beta1 cronJob on an update to v1 job,only if v1 job is not created yet
|
||||
if _, err := r.context.Clientset.BatchV1().CronJobs(objectMeta.Namespace).Get(r.opManagerContext, prunerName, metav1.GetOptions{}); err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
err = r.client.Delete(r.opManagerContext, &v1beta1.CronJob{ObjectMeta: objectMeta})
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
return errors.Wrapf(err, "failed to delete CronJob v1Beta1 %q", prunerName)
|
||||
logger.Debugf("could not delete CronJob v1Beta1 %q. %v", prunerName, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getCrashDirInitContainer(cephCluster cephv1.CephCluster) corev1.Container {
|
||||
|
||||
Reference in new issue
Block a user