From b6d955758e4e4be3abe6fc5f40ebc9ec999f190e Mon Sep 17 00:00:00 2001 From: David Ansari Date: Fri, 19 Mar 2021 09:45:24 +0100 Subject: [PATCH] Don't consider stderr CLI output to be an error Between RabbitMQ v3.8.14 and v3.8.15, the command `rabbitmq-queues rebalance quorum` outputs warn messages like `10:59:50.674 [warn] Node :"rabbit@r1-server-0.r1-nodes.default" only contains 1 queues, do nothing` to stderr. Although this CLI command exits with 0, the operator considers this as a failure, retrying to execute that command. The operator logs the following: `2021-03-19T08:39:56.305Z ERROR controller-runtime.manager.controller.rabbitmqcluster Reconciler error {"reconciler group": "rabbitmq.com", "reconciler kind": "RabbitmqCluster", "name": "r1", "namespace": "default", "error": "failed to run queue rebalance on pod r1-server-0:` In general when CLI commands output to stderr, it doesn't mean that there was an error. So, in this commit we only consider non-zero exit codes as error. --- config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml | 2 +- controllers/pod_executor.go | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml b/config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml index 62f631738..858d781d6 100644 --- a/config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml +++ b/config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml @@ -3499,7 +3499,7 @@ spec: additionalPlugins: description: 'List of plugins to enable in addition to essential plugins: rabbitmq_management, rabbitmq_prometheus, and rabbitmq_peer_discovery_k8s.' items: - description: kubebuilder validating tags 'Pattern' and 'MaxLength' must be specified on string type. Alias type 'string' as 'Plugin' to specify schema validation on items of the list 'AdditionalPlugins' + description: A Plugin to enable on the RabbitmqCluster. maxLength: 100 pattern: ^\w+$ type: string diff --git a/controllers/pod_executor.go b/controllers/pod_executor.go index 2f69055e5..a57649637 100644 --- a/controllers/pod_executor.go +++ b/controllers/pod_executor.go @@ -3,7 +3,7 @@ package controllers import ( "bufio" "bytes" - "fmt" + corev1 "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" @@ -48,12 +48,6 @@ func (p *rabbitmqPodExecutor) Exec(clientset *kubernetes.Clientset, clusterConfi Stdin: nil, Tty: false, }) - if err != nil { - return stdOut.String(), stdErr.String(), err - } - if stdErr.Len() > 0 { - return stdOut.String(), stdErr.String(), fmt.Errorf("%v", stdErr) - } - return stdOut.String(), "", nil + return stdOut.String(), stdErr.String(), err }