From d63d9b7d4d3cae0cf899ea1207c768d33ab1aaa5 Mon Sep 17 00:00:00 2001 From: Julien Girardin Date: Mon, 28 Dec 2020 22:28:33 +0100 Subject: [PATCH] ceph: change external rgw detection, not relying on cluster After #6217, internal rgw spawning on external cluster was still broken, operator claiming: ``` ceph-object-controller: failed to reconcile failed to create object store deployments: failed to reconcile external endpoint: failed to create or update object store "arch-cloud" endpoint: failed to create endpoint "rook-ceph-rgw-arch-cloud". Endpoints "rook-ceph-rgw-arch-cloud" is invalid: subsets[0]: Required value: must specify `addresses` or `notReadyAddresses` ``` To spawn internal rgw for external cluster, changes detection of what mean 'internal' for rgw and only use the externalRgwEndpoints list for that independently of the status of the cluster Now there is multiple posibilities: * internal cluster and internal rgw pods: "normal case" * external cluster and internal rgw pods: <= now working with the PR * external cluster and external rgw pods: the external case * internal cluster and external rgw pods: <= new case that could exist Signed-off-by: Julien Girardin --- pkg/apis/ceph.rook.io/v1/object.go | 4 ++++ pkg/operator/ceph/object/controller.go | 2 +- pkg/operator/ceph/object/rgw.go | 7 ------- pkg/operator/ceph/object/spec.go | 2 +- pkg/operator/ceph/object/spec_test.go | 10 ---------- 5 files changed, 6 insertions(+), 19 deletions(-) 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{ {