From 6f4f10a3c597e88bfc373ecd4e4b51c89bb12a1b Mon Sep 17 00:00:00 2001 From: Jiffin Tony Thottan Date: Thu, 9 Jun 2022 18:12:49 +0530 Subject: [PATCH] object: add the external rgw server check properly In object package code, external rgw server check is whether ceph cluster is external instead of rgw. Correcting such scenarios in the code base. Signed-off-by: Jiffin Tony Thottan --- pkg/operator/ceph/object/objectstore.go | 8 +++----- pkg/operator/ceph/object/rgw.go | 2 +- pkg/operator/ceph/object/user/controller.go | 12 +++++------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/pkg/operator/ceph/object/objectstore.go b/pkg/operator/ceph/object/objectstore.go index c2921ca48..291518f03 100644 --- a/pkg/operator/ceph/object/objectstore.go +++ b/pkg/operator/ceph/object/objectstore.go @@ -874,11 +874,9 @@ func getDashboardUser(context *Context) (ObjectUser, error) { SystemUser: true, } - if !context.CephClusterSpec.External.Enable { - // Retrieve RGW Dashboard credentials if some are already set - if err := retrieveDashboardAPICredentials(context, &user); err != nil { - return user, errors.Wrapf(err, "failed to retrieve RGW Dashboard credentials for %q user", DashboardUser) - } + // Retrieve RGW Dashboard credentials if some are already set + if err := retrieveDashboardAPICredentials(context, &user); err != nil { + return user, errors.Wrapf(err, "failed to retrieve RGW Dashboard credentials for %q user", DashboardUser) } return user, nil diff --git a/pkg/operator/ceph/object/rgw.go b/pkg/operator/ceph/object/rgw.go index a5d6eda63..87628ff88 100644 --- a/pkg/operator/ceph/object/rgw.go +++ b/pkg/operator/ceph/object/rgw.go @@ -226,7 +226,7 @@ func (c *clusterConfig) startRGWPods(realmName, zoneGroupName, zoneName string) func (c *clusterConfig) deleteStore() { logger.Infof("deleting object store %q from namespace %q", c.store.Name, c.store.Namespace) - if !c.clusterSpec.External.Enable { + if !c.store.Spec.IsExternal() { // Delete rgw CephX keys and configuration in centralized mon database for i := 0; i < int(c.store.Spec.Gateway.Instances); i++ { daemonLetterID := k8sutil.IndexToName(i) diff --git a/pkg/operator/ceph/object/user/controller.go b/pkg/operator/ceph/object/user/controller.go index a57a15f50..225ef1ae7 100644 --- a/pkg/operator/ceph/object/user/controller.go +++ b/pkg/operator/ceph/object/user/controller.go @@ -478,15 +478,15 @@ func (r *ReconcileObjectStoreUser) reconcileCephUserSecret(cephObjectStoreUser * } func (r *ReconcileObjectStoreUser) objectStoreInitialized(cephObjectStoreUser *cephv1.CephObjectStoreUser) error { - _, err := r.getObjectStore(cephObjectStoreUser.Spec.Store) + cephObjectStore, err := r.getObjectStore(cephObjectStoreUser.Spec.Store) if err != nil { return err } logger.Debug("CephObjectStore exists") - // If the cluster is external just return + // If the rgw is external just return // since there are no pods running - if r.cephClusterSpec.External.Enable { + if cephObjectStore.Spec.IsExternal() { return nil } @@ -571,10 +571,8 @@ func (r *ReconcileObjectStoreUser) validateUser(u *cephv1.CephObjectStoreUser) e if u.Namespace == "" { return errors.New("missing namespace") } - if !r.cephClusterSpec.External.Enable { - if u.Spec.Store == "" { - return errors.New("missing store") - } + if u.Spec.Store == "" { + return errors.New("missing store") } return nil }