From ecc67faa5c1942cb80c2726b25dcc9e241cb48bd Mon Sep 17 00:00:00 2001 From: yati1998 Date: Wed, 27 Jul 2022 09:24:19 +0530 Subject: [PATCH] csi: introduce new log level for sidecars This commit introduces new log level called csidecarLogLevel for the sidecars which are not maintained by the csi-driver. This will allow to have different configuration options for the sidecars like snapshotter, resizer, attacher and provisioner containers which will help to avoid the spamming of logs to an extent. Signed-off-by: yati1998 --- Documentation/Helm-Charts/operator-chart.md | 3 ++- deploy/charts/rook-ceph/templates/configmap.yaml | 3 +++ deploy/charts/rook-ceph/values.yaml | 5 ++++- deploy/examples/operator-openshift.yaml | 6 +++++- deploy/examples/operator.yaml | 6 +++++- pkg/operator/ceph/csi/csi.go | 11 +++++++++++ pkg/operator/ceph/csi/spec.go | 4 +++- .../cephfs/csi-cephfsplugin-provisioner-dep.yaml | 8 ++++---- .../template/nfs/csi-nfsplugin-provisioner-dep.yaml | 2 +- .../template/rbd/csi-rbdplugin-provisioner-dep.yaml | 8 ++++---- 10 files changed, 42 insertions(+), 14 deletions(-) diff --git a/Documentation/Helm-Charts/operator-chart.md b/Documentation/Helm-Charts/operator-chart.md index 8453766f0..ce9ab8bfa 100644 --- a/Documentation/Helm-Charts/operator-chart.md +++ b/Documentation/Helm-Charts/operator-chart.md @@ -73,7 +73,8 @@ The following tables lists the configurable parameters of the rook-operator char | `csi.rbdFSGroupPolicy` | Policy for modifying a volume's ownership or permissions when the RBD PVC is being mounted | `ReadWriteOnceWithFSType` | | `csi.cephFSFSGroupPolicy` | Policy for modifying a volume's ownership or permissions when the CephFS PVC is being mounted | `ReadWriteOnceWithFSType` | | `csi.nfsFSGroupPolicy` | Policy for modifying a volume's ownership or permissions when the NFS PVC is being mounted | `ReadWriteOnceWithFSType` | -| `csi.logLevel` | Set logging level for csi containers. Supported values from 0 to 5. 0 for general useful logs, 5 for trace level verbosity. | `0` | +| `csi.logLevel` | Set logging level for cephCSI containers maintained by the cephCSI. Supported values from 0 to 5. 0 for general useful logs, 5 for trace level verbosity. | `0` | +| `csi.sidecarLogLevel` | Set logging level for cephCSI sidecar containers. Supported values from 0 to 5. 0 for general useful logs (the default), 5 for trace level verbosity. | `0` | | `csi.grpcTimeoutInSeconds` | Set GRPC timeout for csi containers. | `150` | | `csi.provisionerReplicas` | Set replicas for csi provisioner deployment. | `2` | | `csi.enableGrpcMetrics` | Enable Ceph CSI GRPC Metrics. | `false` | diff --git a/deploy/charts/rook-ceph/templates/configmap.yaml b/deploy/charts/rook-ceph/templates/configmap.yaml index ec5a8184e..2864d73f8 100644 --- a/deploy/charts/rook-ceph/templates/configmap.yaml +++ b/deploy/charts/rook-ceph/templates/configmap.yaml @@ -174,6 +174,9 @@ data: {{- if .Values.csi.logLevel }} CSI_LOG_LEVEL: {{ .Values.csi.logLevel | quote }} {{- end }} +{{- if .Values.csi.sidecarLogLevel }} + CSI_SIDECAR_LOG_LEVEL: {{ .Values.csi.sidecarLogLevel | quote }} +{{- end }} {{- if .Values.csi.grpcTimeoutInSeconds }} CSI_GRPC_TIMEOUT_SECONDS: {{ .Values.csi.grpcTimeoutInSeconds | quote }} {{- end }} diff --git a/deploy/charts/rook-ceph/values.yaml b/deploy/charts/rook-ceph/values.yaml index 02762181c..47cac5fd6 100644 --- a/deploy/charts/rook-ceph/values.yaml +++ b/deploy/charts/rook-ceph/values.yaml @@ -101,9 +101,12 @@ csi: # Set replicas for csi provisioner deployment. provisionerReplicas: 2 - # Set logging level for csi containers. + # Set logging level for cephCSI containers maintained by the cephCSI. # Supported values from 0 to 5. 0 for general useful logs, 5 for trace level verbosity. #logLevel: 0 + # Set logging level for Kubernetes-csi sidecar containers. + # Supported values from 0 to 5. 0 for general useful logs (the default), 5 for trace level verbosity. + #sidecarLogLevel: 0 # CSI RBD plugin daemonset update strategy, supported values are OnDelete and RollingUpdate. # Default value is RollingUpdate. #rbdPluginUpdateStrategy: OnDelete diff --git a/deploy/examples/operator-openshift.yaml b/deploy/examples/operator-openshift.yaml index a14c039f5..2d6389e38 100644 --- a/deploy/examples/operator-openshift.yaml +++ b/deploy/examples/operator-openshift.yaml @@ -127,10 +127,14 @@ data: # there is significant drop in read/write performance. # CSI_ENABLE_HOST_NETWORK: "true" - # Set logging level for csi containers. + # Set logging level for cephCSI containers maintained by the cephCSI. # Supported values from 0 to 5. 0 for general useful logs, 5 for trace level verbosity. # CSI_LOG_LEVEL: "0" + # Set logging level for Kubernetes-csi sidecar containers. + # Supported values from 0 to 5. 0 for general useful logs, 5 for trace level verbosity. + # CSI_SIDECAR_LOG_LEVEL: "0" + # Set replicas for csi provisioner deployment. CSI_PROVISIONER_REPLICAS: "2" diff --git a/deploy/examples/operator.yaml b/deploy/examples/operator.yaml index 911a7b1fd..e1a6a67ab 100644 --- a/deploy/examples/operator.yaml +++ b/deploy/examples/operator.yaml @@ -42,10 +42,14 @@ data: # there is significant drop in read/write performance. # CSI_ENABLE_HOST_NETWORK: "true" - # Set logging level for csi containers. + # Set logging level for cephCSI containers maintained by the cephCSI. # Supported values from 0 to 5. 0 for general useful logs, 5 for trace level verbosity. # CSI_LOG_LEVEL: "0" + # Set logging level for Kubernetes-csi sidecar containers. + # Supported values from 0 to 5. 0 for general useful logs (the default), 5 for trace level verbosity. + # CSI_SIDECAR_LOG_LEVEL: "0" + # Set replicas for csi provisioner deployment. CSI_PROVISIONER_REPLICAS: "2" diff --git a/pkg/operator/ceph/csi/csi.go b/pkg/operator/ceph/csi/csi.go index b735c77d5..14b110c10 100644 --- a/pkg/operator/ceph/csi/csi.go +++ b/pkg/operator/ceph/csi/csi.go @@ -217,6 +217,17 @@ func (r *ReconcileCSI) setParams(ver *version.Info) error { } } + sidecarLogLevel := k8sutil.GetValue(r.opConfig.Parameters, "CSI_SIDECAR_LOG_LEVEL", "") + CSIParam.SidecarLogLevel = defaultSidecarLogLevel + if sidecarLogLevel != "" { + l, err := strconv.ParseUint(sidecarLogLevel, 10, 8) + if err != nil { + logger.Errorf("failed to parse CSI_SIDECAR_LOG_LEVEL. Defaulting to %d. %v", defaultSidecarLogLevel, err) + } else { + CSIParam.SidecarLogLevel = uint8(l) + } + } + CSIParam.ProvisionerReplicas = defaultProvisionerReplicas nodes, err := r.context.Clientset.CoreV1().Nodes().List(r.opManagerContext, metav1.ListOptions{}) if err == nil { diff --git a/pkg/operator/ceph/csi/spec.go b/pkg/operator/ceph/csi/spec.go index 5763be922..29979eb56 100644 --- a/pkg/operator/ceph/csi/spec.go +++ b/pkg/operator/ceph/csi/spec.go @@ -70,6 +70,7 @@ type Param struct { EnableCSIEncryption bool EnableLiveness bool LogLevel uint8 + SidecarLogLevel uint8 CephFSGRPCMetricsPort uint16 CephFSLivenessMetricsPort uint16 RBDGRPCMetricsPort uint16 @@ -214,7 +215,8 @@ const ( detectCSIVersionName = "rook-ceph-csi-detect-version" // default log level for csi containers - defaultLogLevel uint8 = 0 + defaultLogLevel uint8 = 0 + defaultSidecarLogLevel uint8 = 0 // GRPC timeout. defaultGRPCTimeout = 150 diff --git a/pkg/operator/ceph/csi/template/cephfs/csi-cephfsplugin-provisioner-dep.yaml b/pkg/operator/ceph/csi/template/cephfs/csi-cephfsplugin-provisioner-dep.yaml index 4a726442f..a4c023e6e 100644 --- a/pkg/operator/ceph/csi/template/cephfs/csi-cephfsplugin-provisioner-dep.yaml +++ b/pkg/operator/ceph/csi/template/cephfs/csi-cephfsplugin-provisioner-dep.yaml @@ -25,7 +25,7 @@ spec: - name: csi-attacher image: {{ .AttacherImage }} args: - - "--v={{ .LogLevel }}" + - "--v={{ .SidecarLogLevel }}" - "--csi-address=$(ADDRESS)" - "--leader-election=true" - "--timeout={{ .GRPCTimeout }}" @@ -45,7 +45,7 @@ spec: image: {{ .SnapshotterImage }} args: - "--csi-address=$(ADDRESS)" - - "--v={{ .LogLevel }}" + - "--v={{ .SidecarLogLevel }}" - "--timeout={{ .GRPCTimeout }}" - "--leader-election=true" - "--leader-election-namespace={{ .Namespace }}" @@ -65,7 +65,7 @@ spec: image: {{ .ResizerImage }} args: - "--csi-address=$(ADDRESS)" - - "--v={{ .LogLevel }}" + - "--v={{ .SidecarLogLevel }}" - "--timeout={{ .GRPCTimeout }}" - "--leader-election=true" - "--leader-election-namespace={{ .Namespace }}" @@ -84,7 +84,7 @@ spec: image: {{ .ProvisionerImage }} args: - "--csi-address=$(ADDRESS)" - - "--v={{ .LogLevel }}" + - "--v={{ .SidecarLogLevel }}" - "--timeout={{ .GRPCTimeout }}" - "--retry-interval-start=500ms" - "--leader-election=true" diff --git a/pkg/operator/ceph/csi/template/nfs/csi-nfsplugin-provisioner-dep.yaml b/pkg/operator/ceph/csi/template/nfs/csi-nfsplugin-provisioner-dep.yaml index 35f8c61bf..ad106b38b 100644 --- a/pkg/operator/ceph/csi/template/nfs/csi-nfsplugin-provisioner-dep.yaml +++ b/pkg/operator/ceph/csi/template/nfs/csi-nfsplugin-provisioner-dep.yaml @@ -25,7 +25,7 @@ spec: image: {{ .ProvisionerImage }} args: - "--csi-address=$(ADDRESS)" - - "--v={{ .LogLevel }}" + - "--v={{ .SidecarLogLevel }}" - "--timeout={{ .GRPCTimeout }}" - "--retry-interval-start=500ms" - "--leader-election=true" diff --git a/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin-provisioner-dep.yaml b/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin-provisioner-dep.yaml index eea5539c5..5deaca9c9 100644 --- a/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin-provisioner-dep.yaml +++ b/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin-provisioner-dep.yaml @@ -26,7 +26,7 @@ spec: image: {{ .ProvisionerImage }} args: - "--csi-address=$(ADDRESS)" - - "--v={{ .LogLevel }}" + - "--v={{ .SidecarLogLevel }}" - "--timeout={{ .GRPCTimeout }}" - "--retry-interval-start=500ms" - "--leader-election=true" @@ -47,7 +47,7 @@ spec: image: {{ .ResizerImage }} args: - "--csi-address=$(ADDRESS)" - - "--v={{ .LogLevel }}" + - "--v={{ .SidecarLogLevel }}" - "--timeout={{ .GRPCTimeout }}" - "--leader-election=true" - "--leader-election-namespace={{ .Namespace }}" @@ -65,7 +65,7 @@ spec: - name: csi-attacher image: {{ .AttacherImage }} args: - - "--v={{ .LogLevel }}" + - "--v={{ .SidecarLogLevel }}" - "--timeout={{ .GRPCTimeout }}" - "--csi-address=$(ADDRESS)" - "--leader-election=true" @@ -85,7 +85,7 @@ spec: image: {{ .SnapshotterImage }} args: - "--csi-address=$(ADDRESS)" - - "--v={{ .LogLevel }}" + - "--v={{ .SidecarLogLevel }}" - "--timeout={{ .GRPCTimeout }}" - "--leader-election=true" - "--leader-election-namespace={{ .Namespace }}"