Merge pull request #10260 from rook/mergify/bp/release-1.9/pr-10161
operator: set 'rook-version' in mon k/v store (backport #10161)
This commit is contained in:
2 files changed
+30
No files matched your search
@@ -40,6 +40,7 @@ import (
|
||||
"github.com/rook/rook/pkg/operator/ceph/csi"
|
||||
cephver "github.com/rook/rook/pkg/operator/ceph/version"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
rookversion "github.com/rook/rook/pkg/version"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -486,6 +487,9 @@ func (c *cluster) skipMDSSanityChecks(skip bool) error {
|
||||
// It gets executed right after the main mon Start() method
|
||||
// Basically, it is executed between the monitors and the manager sequence
|
||||
func (c *cluster) postMonStartupActions() error {
|
||||
// Identify this as a rook cluster for Ceph telemetry by setting the Rook version.
|
||||
c.setRookVersionInCephKVStore()
|
||||
|
||||
// Create CSI Kubernetes Secrets
|
||||
err := csi.CreateCSISecrets(c.context, c.ClusterInfo)
|
||||
if err != nil {
|
||||
@@ -572,3 +576,14 @@ func (c *cluster) configureMsgr2() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// set the Rook version in Ceph's k/v store to allow Rook clusters that enable Ceph telemetry to be
|
||||
// identified easily as Rook clusters while additionally providing potentially useful information
|
||||
// about the version of Rook that is managing the cluster.
|
||||
// e.g., rook-version=v1.8.7
|
||||
func (c *cluster) setRookVersionInCephKVStore() {
|
||||
ms := config.GetMonStore(c.context, c.ClusterInfo)
|
||||
if err := ms.SetKeyValue(k8sutil.RookVersionLabelKey, rookversion.Version); err != nil {
|
||||
logger.Warningf("failed to set telemetry key; this cluster may not be identifiable by ceph telemetry as a Rook cluster. %v", err)
|
||||
}
|
||||
}
|
||||
@@ -192,3 +192,18 @@ func (m *MonStore) DeleteAll(options ...Option) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetKeyValue sets an arbitrary key/value pair in Ceph's general purpose (as opposed to
|
||||
// configuration-specific) key/value store. Keys and values can be any arbitrary string including
|
||||
// spaces, underscores, dashes, and slashes.
|
||||
// See: https://docs.ceph.com/en/quincy/man/8/ceph/#config-key
|
||||
func (m *MonStore) SetKeyValue(key, value string) error {
|
||||
logger.Debugf("setting %q=%q option in the mon config-key store", key, value)
|
||||
args := []string{"config-key", "set", key, value}
|
||||
cephCmd := client.NewCephCommand(m.context, m.clusterInfo, args)
|
||||
out, err := cephCmd.RunWithTimeout(exec.CephCommandsTimeout)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to set %q in the mon config-key store. output: %s", key, string(out))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user