diff --git a/internal/controller/nodeagent.go b/internal/controller/nodeagent.go index fa28ae2816..fccd8d9e47 100644 --- a/internal/controller/nodeagent.go +++ b/internal/controller/nodeagent.go @@ -700,6 +700,10 @@ func (r *DataProtectionApplicationReconciler) customizeNodeAgentDaemonset(ds *ap nodeAgentContainer.Args = append(nodeAgentContainer.Args, fmt.Sprintf("--log-format=%s", dpa.Spec.LogFormat)) } + if dpa.Spec.Configuration.Velero.LogLevel != "" { + nodeAgentContainer.Args = append(nodeAgentContainer.Args, fmt.Sprintf("--log-level=%s", dpa.Spec.Configuration.Velero.LogLevel)) + } + // Apply unsupported server args from the specified ConfigMap. // This will completely override any previously set args for the node-agent server. // If the ConfigMap exists and is not empty, its key-value pairs will be used as the new CLI arguments. diff --git a/internal/controller/nodeagent_test.go b/internal/controller/nodeagent_test.go index 334e0e1716..7513b4e60a 100644 --- a/internal/controller/nodeagent_test.go +++ b/internal/controller/nodeagent_test.go @@ -253,6 +253,7 @@ type TestBuiltNodeAgentDaemonSetOptions struct { dataMoverPrepareTimeout *string resourceTimeout *string logFormat *string + logLevel *string toleration []corev1.Toleration nodeSelector map[string]string disableFsBackup *bool @@ -572,6 +573,9 @@ func createTestBuiltNodeAgentDaemonSet(options TestBuiltNodeAgentDaemonSetOption if len(options.priorityClassName) > 0 { testBuiltNodeAgentDaemonSet.Spec.Template.Spec.PriorityClassName = options.priorityClassName } + if options.logLevel != nil { + testBuiltNodeAgentDaemonSet.Spec.Template.Spec.Containers[0].Args = append(testBuiltNodeAgentDaemonSet.Spec.Template.Spec.Containers[0].Args, fmt.Sprintf("--log-level=%s", *options.logLevel)) + } return testBuiltNodeAgentDaemonSet } @@ -834,6 +838,25 @@ func TestDPAReconciler_buildNodeAgentDaemonset(t *testing.T) { logFormat: ptr.To("text"), }), }, + { + name: "valid DPA CR with LogLevel set to debug, NodeAgent DaemonSet is built with LogLevel set to debug", + dpa: createTestDpaWith( + nil, + oadpv1alpha1.DataProtectionApplicationSpec{ + Configuration: &oadpv1alpha1.ApplicationConfig{ + Velero: &oadpv1alpha1.VeleroConfig{ + LogLevel: "debug", + }, + NodeAgent: &oadpv1alpha1.NodeAgentConfig{}, + }, + }, + ), + clientObjects: []client.Object{testGenericInfrastructure}, + nodeAgentDaemonSet: testNodeAgentDaemonSet.DeepCopy(), + wantNodeAgentDaemonSet: createTestBuiltNodeAgentDaemonSet(TestBuiltNodeAgentDaemonSetOptions{ + logLevel: ptr.To("debug"), + }), + }, { name: "valid DPA CR with DataMoverPrepareTimeout and ResourceTimeout, NodeAgent DaemonSet is built with DataMoverPrepareTimeout and ResourceTimeout", dpa: createTestDpaWith(