diff --git a/pkg/apis/ceph.rook.io/v1/object.go b/pkg/apis/ceph.rook.io/v1/object.go index 5c3c3e31e..d3bc542e9 100644 --- a/pkg/apis/ceph.rook.io/v1/object.go +++ b/pkg/apis/ceph.rook.io/v1/object.go @@ -20,6 +20,10 @@ func (s *ObjectStoreSpec) IsMultisite() bool { return s.Zone.Name != "" } +func (s *ObjectStoreSpec) IsExternal() bool { + return len(s.Gateway.ExternalRgwEndpoints) != 0 +} + func (s *ObjectRealmSpec) IsPullRealm() bool { return s.Pull.Endpoint != "" } diff --git a/pkg/operator/ceph/object/controller.go b/pkg/operator/ceph/object/controller.go index ee5136b25..a115c32c7 100644 --- a/pkg/operator/ceph/object/controller.go +++ b/pkg/operator/ceph/object/controller.go @@ -308,7 +308,7 @@ func (r *ReconcileCephObjectStore) reconcileCreateObjectStore(cephObjectStore *c var serviceIP string var err error - if r.clusterSpec.External.Enable { + if cephObjectStore.Spec.IsExternal() { logger.Info("reconciling external object store") // RECONCILE SERVICE diff --git a/pkg/operator/ceph/object/rgw.go b/pkg/operator/ceph/object/rgw.go index 6ca89eb96..30fd51de6 100644 --- a/pkg/operator/ceph/object/rgw.go +++ b/pkg/operator/ceph/object/rgw.go @@ -305,13 +305,6 @@ func (r *ReconcileCephObjectStore) validateStore(s *cephv1.CephObjectStore) erro } } - // Fail if we detected an external CephCluster CR and the list of endpoints is empty - if r.clusterSpec.External.Enable && r.clusterInfo.CephCred.Username != cephclient.AdminUsername { - if len(s.Spec.Gateway.ExternalRgwEndpoints) == 0 { - return errors.New("ceph cluster is external but externalRgwEndpoints list is empty") - } - } - return nil } diff --git a/pkg/operator/ceph/object/spec.go b/pkg/operator/ceph/object/spec.go index 71147c487..d393b9687 100644 --- a/pkg/operator/ceph/object/spec.go +++ b/pkg/operator/ceph/object/spec.go @@ -259,7 +259,7 @@ func (c *clusterConfig) generateService(cephObjectStore *cephv1.CephObjectStore) destPort := c.generateLiveProbePort() // When the cluster is external we must use the same one as the gateways are listening on - if c.clusterSpec.External.Enable { + if cephObjectStore.Spec.IsExternal() { destPort.IntVal = cephObjectStore.Spec.Gateway.Port } else { // If the cluster is not external we add the Selector diff --git a/pkg/operator/ceph/object/spec_test.go b/pkg/operator/ceph/object/spec_test.go index e6ca79f41..46237879c 100644 --- a/pkg/operator/ceph/object/spec_test.go +++ b/pkg/operator/ceph/object/spec_test.go @@ -189,16 +189,6 @@ func TestValidateSpec(t *testing.T) { err = r.validateStore(s) assert.Nil(t, err) - // external with no endpoints but ok since client.admin is used - r.clusterSpec.External.Enable = true - err = r.validateStore(s) - assert.NoError(t, err) - - // external with no endpoints, failure - r.clusterInfo.CephCred.Username = "client.external" - err = r.validateStore(s) - assert.NotNil(t, err) - // external with endpoints, success s.Spec.Gateway.ExternalRgwEndpoints = []v1.EndpointAddress{ {