From 16b5b0214762429f450d03adb3a4e0e52c73b9ae Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Thu, 1 Dec 2022 16:49:32 -0700 Subject: [PATCH] core: set env var for ceph msgr to use random nonce Ceph will use a random nonce for the msgr daemons as long as they are running as PID 1 or have the environment variable CEPH_USE_RANDOM_NONCE set to indicate running in a containerized environment. While the Ceph daemons in Rook are expected to run in PID 1, there are some environments where the container runtime may choose to run something else such as /usr/bin/pod as PID 1. The side effect then is that ceph uses the pid as the nonce and causes problems when the daemons restart with the same PID. Signed-off-by: Travis Nielsen (cherry picked from commit 31a8fb1e6a210d884d493168427766009264bc9f) --- pkg/operator/ceph/test/containers.go | 5 ++++- pkg/operator/k8sutil/pod.go | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/operator/ceph/test/containers.go b/pkg/operator/ceph/test/containers.go index 093ff0ddc..aa4181844 100644 --- a/pkg/operator/ceph/test/containers.go +++ b/pkg/operator/ceph/test/containers.go @@ -30,7 +30,7 @@ var requiredEnvVars = []string{ "CONTAINER_IMAGE", "POD_NAME", "POD_NAMESPACE", "NODE_NAME", "ROOK_CEPH_MON_HOST", "ROOK_CEPH_MON_INITIAL_MEMBERS", "POD_CPU_LIMIT", "POD_MEMORY_LIMIT", "POD_MEMORY_REQUEST", - "POD_CPU_REQUEST", + "POD_CPU_REQUEST", "CEPH_USE_RANDOM_NONCE", } // A ContainersTester is a helper exposing methods for testing required Ceph specifications common @@ -130,6 +130,9 @@ func (ct *ContainersTester) AssertEnvVarsContainCephRequirements() { case "POD_CPU_REQUEST": assert.Equal(ct.t, "requests.cpu", e.ValueFrom.ResourceFieldRef.Resource, "POD_CPU_REQUEST env var does not have the appropriate source:", e) + case "CEPH_USE_RANDOM_NONCE": + assert.Equal(ct.t, "true", e.Value, + "CEPH_USE_RANDOM_NONCE env var does not have the appropriate source:", e) } } vars := FindDuplicateEnvVars(c) diff --git a/pkg/operator/k8sutil/pod.go b/pkg/operator/k8sutil/pod.go index e13301c41..f533ec9b8 100644 --- a/pkg/operator/k8sutil/pod.go +++ b/pkg/operator/k8sutil/pod.go @@ -305,6 +305,9 @@ func ClusterDaemonEnvVars(image string) []v1.EnvVar { // If request.cpu is not set in the pod definition, Kubernetes will use the formula "requests.cpu = limits.cpu" during pods's scheduling // Kubernetes will set this variable to 0 or equal to limits.cpu if set {Name: "POD_CPU_REQUEST", ValueFrom: &v1.EnvVarSource{ResourceFieldRef: &v1.ResourceFieldSelector{Resource: "requests.cpu"}}}, + + // All ceph daemons using msgr in a containerized environment expect to set a random nonce at startup + {Name: "CEPH_USE_RANDOM_NONCE", Value: "true"}, } }