From 6888d545d298ea450dd49f6267dafd7d8750df11 Mon Sep 17 00:00:00 2001 From: Blaine Gardner Date: Wed, 18 May 2022 13:20:58 -0600 Subject: [PATCH] operator: rename telemetry rook-version to rook/version The Rook and Ceph teams settled on using slashes to separate Rook telemetry items into a hierarchy in https://github.com/rook/rook/pull/10254. Rename the config-key used to `rook/version`, and create a `telemetry` package to define the telemetry key constants. Signed-off-by: Blaine Gardner --- pkg/operator/ceph/cluster/cluster.go | 15 +------ .../ceph/cluster/telemetry/telemetry.go | 44 +++++++++++++++++++ 2 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 pkg/operator/ceph/cluster/telemetry/telemetry.go diff --git a/pkg/operator/ceph/cluster/cluster.go b/pkg/operator/ceph/cluster/cluster.go index 7249c46ed..8fbb0f28f 100755 --- a/pkg/operator/ceph/cluster/cluster.go +++ b/pkg/operator/ceph/cluster/cluster.go @@ -34,12 +34,12 @@ import ( "github.com/rook/rook/pkg/operator/ceph/cluster/mgr" "github.com/rook/rook/pkg/operator/ceph/cluster/mon" "github.com/rook/rook/pkg/operator/ceph/cluster/osd" + "github.com/rook/rook/pkg/operator/ceph/cluster/telemetry" "github.com/rook/rook/pkg/operator/ceph/config" "github.com/rook/rook/pkg/operator/ceph/controller" "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" @@ -487,7 +487,7 @@ func (c *cluster) skipMDSSanityChecks(skip bool) error { // 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() + telemetry.SetRookVersion(c.context, c.ClusterInfo) // Create CSI Kubernetes Secrets err := csi.CreateCSISecrets(c.context, c.ClusterInfo) @@ -575,14 +575,3 @@ 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) - } -} diff --git a/pkg/operator/ceph/cluster/telemetry/telemetry.go b/pkg/operator/ceph/cluster/telemetry/telemetry.go new file mode 100644 index 000000000..c8f6c1672 --- /dev/null +++ b/pkg/operator/ceph/cluster/telemetry/telemetry.go @@ -0,0 +1,44 @@ +/* +Copyright 2022 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 telemetry codifes the Rook telemetry spec used to record Rook information for Ceph +// telemetry. See: https://docs.ceph.com/en/latest/mgr/telemetry/ +package telemetry + +import ( + "github.com/coreos/pkg/capnslog" + "github.com/rook/rook/pkg/clusterd" + "github.com/rook/rook/pkg/daemon/ceph/client" + "github.com/rook/rook/pkg/operator/ceph/config" + rookversion "github.com/rook/rook/pkg/version" +) + +var logger = capnslog.NewPackageLogger("github.com/rook/rook", "telemetry") + +const ( + RookVersionKey = `rook/version` +) + +// SetRookVersion sets the Rook version in Ceph's config-key store to allow Rook clusters that +// enable Ceph telemetry to be identified easily as Rook clusters while additionally providing +// useful information about the version of Rook that is managing the cluster. +// e.g., rook/version=v1.8.7 +func SetRookVersion(context *clusterd.Context, clusterInfo *client.ClusterInfo) { + ms := config.GetMonStore(context, clusterInfo) + if err := ms.SetKeyValue(RookVersionKey, 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) + } +}