From 8f9df75f7b7067dd1aea5fc64d7ced65edf43a4d Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Mon, 6 Jul 2020 14:35:59 -0600 Subject: [PATCH] ceph: capture logging from the osd daemon The OSD daemon has been missing critical flags for logging to stderr where k8s can capture the logs. Without the --log-to-stderr=true, all the OSD logging was essentially lost until now. Signed-off-by: Travis Nielsen --- pkg/operator/ceph/cluster/osd/spec.go | 8 ++------ pkg/operator/ceph/config/defaults.go | 26 ++++++++++++++++---------- pkg/operator/ceph/controller/spec.go | 5 ++--- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/pkg/operator/ceph/cluster/osd/spec.go b/pkg/operator/ceph/cluster/osd/spec.go index a51b00dea..014da5ad6 100644 --- a/pkg/operator/ceph/cluster/osd/spec.go +++ b/pkg/operator/ceph/cluster/osd/spec.go @@ -233,8 +233,6 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC {Name: "ROOK_IS_DEVICE", Value: "true"}, }...) - var commonArgs []string - // If the OSD runs on PVC if osdProps.onPVC() { // add the PVC size to the pod spec so that if the size changes the OSD will be restarted and pick up the change @@ -249,9 +247,6 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC } } - commonArgs = append(commonArgs, "--default-log-to-file", "false") - commonArgs = append(commonArgs, osdOnSDNFlag(c.Network)...) - var command []string var args []string // If the OSD was prepared with ceph-volume and running on PVC and using the LVM mode @@ -319,7 +314,8 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC volumeMounts = append(volumeMounts, activateOSDContainer.VolumeMounts[0]) } - args = append(args, commonArgs...) + args = append(args, opconfig.LoggingFlags()...) + args = append(args, osdOnSDNFlag(c.Network)...) osdDataDirPath := activateOSDMountPath + osdID if osdProps.onPVC() && osd.CVMode == "lvm" { diff --git a/pkg/operator/ceph/config/defaults.go b/pkg/operator/ceph/config/defaults.go index 4f83aeb43..71510e3cb 100644 --- a/pkg/operator/ceph/config/defaults.go +++ b/pkg/operator/ceph/config/defaults.go @@ -24,11 +24,26 @@ import ( // DefaultFlags returns the default configuration flags Rook will set on the command line for all // calls to Ceph daemons and tools. Values specified here will not be able to be overridden using // the mon's central KV store, and that is (and should be) by intent. -func DefaultFlags(fsid, mountedKeyringPath string, cephVersion version.CephVersion) []string { +func DefaultFlags(fsid, mountedKeyringPath string) []string { flags := []string{ // fsid unnecessary but is a safety to make sure daemons can only connect to their cluster NewFlag("fsid", fsid), NewFlag("keyring", mountedKeyringPath), + } + + flags = append(flags, LoggingFlags()...) + flags = append(flags, StoredMonHostEnvVarFlags()...) + + return flags +} + +// makes it possible to be slightly less verbose to create a ConfigOverride here +func configOverride(who, option, value string) Option { + return Option{Who: who, Option: option, Value: value} +} + +func LoggingFlags() []string { + return []string{ // For containers, we're expected to log everything to stderr NewFlag("log-to-stderr", "true"), NewFlag("err-to-stderr", "true"), @@ -38,15 +53,6 @@ func DefaultFlags(fsid, mountedKeyringPath string, cephVersion version.CephVersi NewFlag("default-log-to-file", "false"), NewFlag("default-mon-cluster-log-to-file", "false"), } - - flags = append(flags, StoredMonHostEnvVarFlags()...) - - return flags -} - -// makes it possible to be slightly less verbose to create a ConfigOverride here -func configOverride(who, option, value string) Option { - return Option{Who: who, Option: option, Value: value} } // DefaultCentralizedConfigs returns the default configuration options Rook will set in Ceph's diff --git a/pkg/operator/ceph/controller/spec.go b/pkg/operator/ceph/controller/spec.go index 0dc660394..46667d614 100644 --- a/pkg/operator/ceph/controller/spec.go +++ b/pkg/operator/ceph/controller/spec.go @@ -263,7 +263,7 @@ func AddVolumeMountSubPath(podSpec *v1.PodSpec, volumeMountName string) { // DaemonFlags returns the command line flags used by all Ceph daemons. func DaemonFlags(cluster *cephconfig.ClusterInfo, daemonID string) []string { return append( - config.DefaultFlags(cluster.FSID, keyring.VolumeMount().KeyringFilePath(), cluster.CephVersion), + config.DefaultFlags(cluster.FSID, keyring.VolumeMount().KeyringFilePath()), config.NewFlag("id", daemonID), // Ceph daemons in Rook will run as 'ceph' instead of 'root' // If we run on a version of Ceph does not these flags it will simply ignore them @@ -272,13 +272,12 @@ func DaemonFlags(cluster *cephconfig.ClusterInfo, daemonID string) []string { // run ceph daemon process under the 'ceph' group config.NewFlag("setgroup", "ceph"), ) - } // AdminFlags returns the command line flags used for Ceph commands requiring admin authentication. func AdminFlags(cluster *cephconfig.ClusterInfo) []string { return append( - config.DefaultFlags(cluster.FSID, keyring.VolumeMount().AdminKeyringFilePath(), cluster.CephVersion), + config.DefaultFlags(cluster.FSID, keyring.VolumeMount().AdminKeyringFilePath()), config.NewFlag("setuser", "ceph"), config.NewFlag("setgroup", "ceph"), )