forked from rook/rook
This commit does multiple things:
* remove support for AllNodes where we would deploy one rgw per node on
all the nodes.
* a transition path is implemented in the code so that if someone has an
existing deployment, daemonsets will be removed and replaced by an
deployments.
* when using "instances", each rgw deployed has its own key which makes
Ceph reporting the exact number of rgw running, see:
```
[root@rook-ceph-operator-775cf575c5-bh4sr /]# ceph -s
cluster:
id: 611fcf39-0669-4864-9a12-debb35c0397a
health: HEALTH_OK
services:
mon: 3 daemons, quorum a,b,c (age 12h)
mgr: a(active, since 12h)
osd: 3 osds: 3 up (since 12h), 3 in (since 12h)
rgw: 3 daemons active (my.store.a, my.store.b, my.store.c)
data:
pools: 6 pools, 600 pgs
objects: 235 objects, 3.8 KiB
usage: 3.0 GiB used, 84 GiB / 87 GiB avail
pgs: 600 active+clean
```
Closes: https://github.com/rook/rook/issues/2474, https://github.com/rook/rook/issues/2957 and https://github.com/rook/rook/issues/3245
Signed-off-by: Sébastien Han <seb@redhat.com>
94 lines
2.6 KiB
Go
94 lines
2.6 KiB
Go
/*
|
|
Copyright 2016 The Rook Authors. All rights reserved.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package object
|
|
|
|
import (
|
|
"testing"
|
|
|
|
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
|
cephconfig "github.com/rook/rook/pkg/daemon/ceph/config"
|
|
cephver "github.com/rook/rook/pkg/operator/ceph/version"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func newConfig() *clusterConfig {
|
|
clusterInfo := &cephconfig.ClusterInfo{
|
|
CephVersion: cephver.Mimic,
|
|
}
|
|
return &clusterConfig{
|
|
store: cephv1.CephObjectStore{
|
|
Spec: cephv1.ObjectStoreSpec{
|
|
Gateway: cephv1.GatewaySpec{},
|
|
}},
|
|
clusterInfo: clusterInfo}
|
|
}
|
|
|
|
func TestPortString(t *testing.T) {
|
|
// No port or secure port
|
|
cfg := newConfig()
|
|
result := cfg.portString()
|
|
assert.Equal(t, "", result)
|
|
|
|
// Insecure port
|
|
cfg = newConfig()
|
|
cfg.store.Spec.Gateway.Port = 80
|
|
result = cfg.portString()
|
|
assert.Equal(t, "80", result)
|
|
|
|
// Secure port
|
|
cfg = newConfig()
|
|
cfg.store.Spec.Gateway.SecurePort = 443
|
|
cfg.store.Spec.Gateway.SSLCertificateRef = "some-k8s-key-secret"
|
|
result = cfg.portString()
|
|
assert.Equal(t, "443s ssl_certificate=/etc/ceph/private/rgw-cert.pem", result)
|
|
|
|
// Both ports
|
|
cfg = newConfig()
|
|
cfg.store.Spec.Gateway.Port = 80
|
|
cfg.store.Spec.Gateway.SecurePort = 443
|
|
cfg.store.Spec.Gateway.SSLCertificateRef = "some-k8s-key-secret"
|
|
result = cfg.portString()
|
|
assert.Equal(t, "80+443s ssl_certificate=/etc/ceph/private/rgw-cert.pem", result)
|
|
|
|
// Secure port requires the cert
|
|
cfg = newConfig()
|
|
cfg.store.Spec.Gateway.SecurePort = 443
|
|
result = cfg.portString()
|
|
assert.Equal(t, "", result)
|
|
}
|
|
|
|
func TestFrontend(t *testing.T) {
|
|
cfg := newConfig()
|
|
cfg.clusterInfo.CephVersion = cephver.Mimic
|
|
|
|
result := rgwFrontend(cfg.clusterInfo.CephVersion)
|
|
assert.Equal(t, "civetweb", result)
|
|
|
|
cfg.clusterInfo.CephVersion = cephver.Nautilus
|
|
result = rgwFrontend(cfg.clusterInfo.CephVersion)
|
|
assert.Equal(t, "beast", result)
|
|
|
|
cfg.clusterInfo.CephVersion = cephver.Octopus
|
|
result = rgwFrontend(cfg.clusterInfo.CephVersion)
|
|
assert.Equal(t, "beast", result)
|
|
}
|
|
|
|
func TestGenerateCephXUser(t *testing.T) {
|
|
fakeUser := generateCephXUser("rook-ceph-rgw-fake-store-fake-user")
|
|
assert.Equal(t, "client.fake.store.fake.user", fakeUser)
|
|
}
|