From dfe060100590d32ab5dd347047a0b09ff7e68d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 10 Feb 2022 17:29:31 +0100 Subject: [PATCH] object: do not check for upgrade on external mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The object child controller should not compare versions if the object store is external. The current version comparison is using the cmdreporter to check the ceph version of the image in the CephCluster spec. In external mode, this image is not set so the cmdreporter fails. Also, this check is only valid for converged mode, so external mode should be skipped. Signed-off-by: Sébastien Han (cherry picked from commit 856b14e60a1a49f61f9f1bf0d63f4f70c13b326a) --- pkg/operator/ceph/object/controller.go | 64 +++++++++++++++----------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/pkg/operator/ceph/object/controller.go b/pkg/operator/ceph/object/controller.go index e8d527549..bad1b51ab 100644 --- a/pkg/operator/ceph/object/controller.go +++ b/pkg/operator/ceph/object/controller.go @@ -34,6 +34,7 @@ import ( "github.com/rook/rook/pkg/operator/ceph/config" opcontroller "github.com/rook/rook/pkg/operator/ceph/controller" "github.com/rook/rook/pkg/operator/ceph/reporting" + cephver "github.com/rook/rook/pkg/operator/ceph/version" "github.com/rook/rook/pkg/operator/k8sutil" "github.com/rook/rook/pkg/util/exec" appsv1 "k8s.io/api/apps/v1" @@ -290,35 +291,46 @@ func (r *ReconcileCephObjectStore) reconcile(request reconcile.Request) (reconci return reconcile.Result{}, cephObjectStore, nil } - // Detect desired CephCluster version - runningCephVersion, desiredCephVersion, err := currentAndDesiredCephVersion( - r.opManagerContext, - r.opConfig.Image, - cephObjectStore.Namespace, - controllerName, - k8sutil.NewOwnerInfo(cephObjectStore, r.scheme), - r.context, - r.clusterSpec, - r.clusterInfo, - ) - if err != nil { - if strings.Contains(err.Error(), opcontroller.UninitializedCephConfigError) { - logger.Info(opcontroller.OperatorNotInitializedMessage) - return opcontroller.WaitForRequeueIfOperatorNotInitialized, cephObjectStore, nil + var desiredCephVersion cephver.CephVersion + if cephObjectStore.Spec.IsExternal() { + // Check the ceph version of the running monitors + desiredCephVersion, err = cephclient.LeastUptodateDaemonVersion(r.context, r.clusterInfo, config.MonType) + if err != nil { + return reconcile.Result{}, nil, errors.Wrapf(err, "failed to retrieve current ceph %q version", config.MonType) + } + + } else { + // Detect desired CephCluster version + runningCephVersion, desiredCephVersion, err := currentAndDesiredCephVersion( + r.opManagerContext, + r.opConfig.Image, + cephObjectStore.Namespace, + controllerName, + k8sutil.NewOwnerInfo(cephObjectStore, r.scheme), + r.context, + r.clusterSpec, + r.clusterInfo, + ) + if err != nil { + if strings.Contains(err.Error(), opcontroller.UninitializedCephConfigError) { + logger.Info(opcontroller.OperatorNotInitializedMessage) + return opcontroller.WaitForRequeueIfOperatorNotInitialized, cephObjectStore, nil + } + return reconcile.Result{}, cephObjectStore, errors.Wrap(err, "failed to detect running and desired ceph version") + } + + // If the version of the Ceph monitor differs from the CephCluster CR image version we assume + // the cluster is being upgraded. So the controller will just wait for the upgrade to finish and + // then versions should match. Obviously using the cmd reporter job adds up to the deployment time + if !reflect.DeepEqual(*runningCephVersion, *desiredCephVersion) { + // Upgrade is in progress, let's wait for the mons to be done + return opcontroller.WaitForRequeueIfCephClusterIsUpgrading, + cephObjectStore, + opcontroller.ErrorCephUpgradingRequeue(desiredCephVersion, runningCephVersion) } - return reconcile.Result{}, cephObjectStore, errors.Wrap(err, "failed to detect running and desired ceph version") } - // If the version of the Ceph monitor differs from the CephCluster CR image version we assume - // the cluster is being upgraded. So the controller will just wait for the upgrade to finish and - // then versions should match. Obviously using the cmd reporter job adds up to the deployment time - if !reflect.DeepEqual(*runningCephVersion, *desiredCephVersion) { - // Upgrade is in progress, let's wait for the mons to be done - return opcontroller.WaitForRequeueIfCephClusterIsUpgrading, - cephObjectStore, - opcontroller.ErrorCephUpgradingRequeue(desiredCephVersion, runningCephVersion) - } - r.clusterInfo.CephVersion = *desiredCephVersion + r.clusterInfo.CephVersion = desiredCephVersion // validate the store settings if err := r.validateStore(cephObjectStore); err != nil {