From a51b76889afdae762eaf75d8bbcbcd20343030f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 10 Sep 2020 10:33:47 +0200 Subject: [PATCH] ceph: allow running rgw in rook with external mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't fail anymore if the cluster is external and user wants to bootstrap rgw gateways in Kubernertes. Closes: https://github.com/rook/rook/issues/6217 Signed-off-by: Sébastien Han --- pkg/operator/ceph/object/rgw.go | 2 +- pkg/operator/ceph/object/spec_test.go | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/operator/ceph/object/rgw.go b/pkg/operator/ceph/object/rgw.go index 0a094e451..200b1854e 100644 --- a/pkg/operator/ceph/object/rgw.go +++ b/pkg/operator/ceph/object/rgw.go @@ -361,7 +361,7 @@ 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.cephClusterSpec.External.Enable { + if r.cephClusterSpec.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") } diff --git a/pkg/operator/ceph/object/spec_test.go b/pkg/operator/ceph/object/spec_test.go index d9c1a6734..2641a953a 100644 --- a/pkg/operator/ceph/object/spec_test.go +++ b/pkg/operator/ceph/object/spec_test.go @@ -22,6 +22,7 @@ import ( cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1" "github.com/rook/rook/pkg/clusterd" + "github.com/rook/rook/pkg/daemon/ceph/client" clienttest "github.com/rook/rook/pkg/daemon/ceph/client/test" cephconfig "github.com/rook/rook/pkg/operator/ceph/config" cephtest "github.com/rook/rook/pkg/operator/ceph/test" @@ -142,6 +143,11 @@ func TestValidateSpec(t *testing.T) { Enable: false, }, }, + clusterInfo: &client.ClusterInfo{ + CephCred: client.CephCred{ + Username: "client.admin", + }, + }, } // valid store @@ -173,9 +179,14 @@ func TestValidateSpec(t *testing.T) { err = r.validateStore(s) assert.Nil(t, err) - // external with no endpoints, failure + // external with no endpoints but ok since client.admin is used r.cephClusterSpec.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