From aa8bf4c7637e8cc50ff698211e3ecc3b59aced13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Tue, 16 Jun 2020 15:12:13 +0200 Subject: [PATCH] ceph: expose operator ceph base image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We now have a new env variable ROOK_CEPH_BASE_IMAGE_VERSION which contains the ceph version on the operator image. Signed-off-by: Sébastien Han --- cmd/rook/ceph/operator.go | 9 ++++++++- cmd/rook/rook/rook.go | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cmd/rook/ceph/operator.go b/cmd/rook/ceph/operator.go index 6e974ad29..8bc19b2c3 100644 --- a/cmd/rook/ceph/operator.go +++ b/cmd/rook/ceph/operator.go @@ -17,6 +17,8 @@ limitations under the License. package ceph import ( + "os" + "github.com/pkg/errors" "github.com/rook/rook/cmd/rook/rook" "github.com/rook/rook/pkg/clusterd" @@ -31,7 +33,10 @@ import ( "github.com/spf13/cobra" ) -const containerName = "rook-ceph-operator" +const ( + containerName = "rook-ceph-operator" + operatorCephBaseImageVersion = "ROOK_CEPH_BASE_IMAGE_VERSION" +) var operatorCmd = &cobra.Command{ Use: "operator", @@ -79,6 +84,8 @@ func startOperator(cmd *cobra.Command, args []string) error { } rookImage := rook.GetOperatorImage(context.Clientset, containerName) + rookBaseImageCephVersion := rook.GetOperatorBaseImageCephVersion(context) + os.Setenv(operatorCephBaseImageVersion, rookBaseImageCephVersion) serviceAccountName := rook.GetOperatorServiceAccount(context.Clientset) op := operator.New(context, volumeAttachment, rookImage, serviceAccountName) err = op.Run() diff --git a/cmd/rook/rook/rook.go b/cmd/rook/rook/rook.go index 40f0bde6b..1305a1a12 100644 --- a/cmd/rook/rook/rook.go +++ b/cmd/rook/rook/rook.go @@ -217,3 +217,14 @@ func TerminateFatal(reason error) { os.Exit(1) } + +// GetOperatorBaseImageCephVersion returns the Ceph version of the operator image +func GetOperatorBaseImageCephVersion(context *clusterd.Context) string { + output, err := context.Executor.ExecuteCommandWithOutput("ceph", "--version") + if err != nil { + logger.Errorf("failed to discover ceph base image version. %v", err) + return "" + } + + return output +}