Files
my-rook-config/pkg/operator/ceph/file/mirror/config.go
T
Sébastien Han b89730d895 ceph: refactor operator initialization sequence
This commit is a large refactor on how the operator starts, stops and
how it starts various sub-components such as the ceph-csi driver. It
also refines the way we cancel orchestrations. We don't use breakpoints
anymore but send our self a SIGUP to reload our controller runtime
manager.
The reload will happen under different circonstances like:

* a new adminission controller secret is created/deleted/changed
* a CephCluster CR is edited

As mentioned earlier, the csi driver now has its own controller, just
like flex. It reacts to change in the operator config map for particular
ROOK_CSI_ fields.

A second new controller for the operator's general config has been
created, it manages:

* the logging level
* the ceph CLI command timeout
* the discovery daemon

The operator reacts much more rapidly to cancellation events by stopping
the manager's context and reloading it.

Signed-off-by: Sébastien Han <seb@redhat.com>
2021-09-17 16:57:12 +02:00

70 lines
2.0 KiB
Go

/*
Copyright 2021 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 mirror
import (
"fmt"
"github.com/rook/rook/pkg/operator/ceph/config"
"github.com/rook/rook/pkg/operator/ceph/config/keyring"
"github.com/rook/rook/pkg/operator/ceph/version"
"github.com/rook/rook/pkg/operator/k8sutil"
)
const (
keyringTemplate = `
[client.fs-mirror]
key = %s
caps mon = "allow profile cephfs-mirror"
caps mgr = "allow r"
caps mds = "allow r"
caps osd = "'allow rw tag cephfs metadata=*, allow r tag cephfs data=*'"
`
user = "client.fs-mirror"
userID = "fs-mirror"
)
var (
// PeerAdditionMinVersion This version includes a number of fixes for snapshots and mirror status
PeerAdditionMinVersion = version.CephVersion{Major: 16, Minor: 2, Extra: 5}
)
// daemonConfig for a single rbd-mirror
type daemonConfig struct {
ResourceName string // the name rook gives to mirror resources in k8s metadata
DataPathMap *config.DataPathMap // location to store data in container
ownerInfo *k8sutil.OwnerInfo
}
func (r *ReconcileFilesystemMirror) generateKeyring(daemonConfig *daemonConfig) (string, error) {
access := []string{
"mon", "allow profile cephfs-mirror",
"mgr", "allow r",
"mds", "allow r",
"osd", "allow rw tag cephfs metadata=*, allow r tag cephfs data=*",
}
s := keyring.GetSecretStore(r.context, r.clusterInfo, daemonConfig.ownerInfo)
key, err := s.GenerateKey(user, access)
if err != nil {
return "", err
}
keyring := fmt.Sprintf(keyringTemplate, key)
return keyring, s.CreateOrUpdate(daemonConfig.ResourceName, keyring)
}