@@ -25,7 +25,6 @@ func (r *RabbitmqClusterReconciler) runRabbitmqCLICommandsIfAnnotated(ctx contex
2525 logger .Info ("not all replicas ready yet; requeuing request to run RabbitMQ CLI commands" )
2626 return 15 * time .Second , nil
2727 }
28-
2928 // Retrieve the plugins config map, if it exists.
3029 pluginsConfig , err := r .configMap (ctx , rmq , rmq .ChildResourceName (resource .PluginsConfigName ))
3130 if client .IgnoreNotFound (err ) != nil {
@@ -72,12 +71,10 @@ func (r *RabbitmqClusterReconciler) runEnableFeatureFlagsCommand(ctx context.Con
7271 cmd := "set -eo pipefail; rabbitmqctl -s list_feature_flags name state stability | (grep 'disabled\\ sstable$' || true) | cut -f 1 | xargs -r -n1 rabbitmqctl enable_feature_flag"
7372 stdout , stderr , err := r .exec (rmq .Namespace , podName , "rabbitmq" , "bash" , "-c" , cmd )
7473 if err != nil {
75- logger .Error (err , "failed to enable all feature flags" ,
76- "pod" , podName ,
77- "command" , cmd ,
78- "stdout" , stdout ,
79- "stderr" , stderr )
80- return err
74+ msg := "failed to enable all feature flags on pod"
75+ logger .Error (err , msg , "pod" , podName , "command" , cmd , "stdout" , stdout , "stderr" , stderr )
76+ r .Recorder .Event (rmq , corev1 .EventTypeWarning , "FailedReconcile" , fmt .Sprintf ("%s %s" , msg , podName ))
77+ return fmt .Errorf ("%s %s: %v" , msg , podName , err )
8178 }
8279 logger .Info ("successfully enabled all feature flags" )
8380 return r .deleteAnnotation (ctx , sts , stsCreateAnnotation )
@@ -95,29 +92,26 @@ func (r *RabbitmqClusterReconciler) runSetPluginsCommand(ctx context.Context, rm
9592 cmd := fmt .Sprintf ("rabbitmq-plugins set %s" , plugins .AsString (" " ))
9693 stdout , stderr , err := r .exec (rmq .Namespace , podName , "rabbitmq" , "sh" , "-c" , cmd )
9794 if err != nil {
98- logger .Error (err , "failed to set plugins" ,
99- "pod" , podName ,
100- "command" , cmd ,
101- "stdout" , stdout ,
102- "stderr" , stderr )
103- return err
95+ msg := "failed to set plugins on pod"
96+ logger .Error (err , msg , "pod" , podName , "command" , cmd , "stdout" , stdout , "stderr" , stderr )
97+ r .Recorder .Event (rmq , corev1 .EventTypeWarning , "FailedReconcile" , fmt .Sprintf ("%s %s" , msg , podName ))
98+ return fmt .Errorf ("%s %s: %v" , msg , podName , err )
10499 }
105100 }
106101 logger .Info ("successfully set plugins" )
107102 return r .deleteAnnotation (ctx , configMap , pluginsUpdateAnnotation )
108103}
109104
110105func (r * RabbitmqClusterReconciler ) runQueueRebalanceCommand (ctx context.Context , rmq * rabbitmqv1beta1.RabbitmqCluster ) error {
106+ logger := ctrl .LoggerFrom (ctx )
111107 podName := fmt .Sprintf ("%s-0" , rmq .ChildResourceName ("server" ))
112108 cmd := "rabbitmq-queues rebalance all"
113109 stdout , stderr , err := r .exec (rmq .Namespace , podName , "rabbitmq" , "sh" , "-c" , cmd )
114110 if err != nil {
115- ctrl .LoggerFrom (ctx ).Error (err , "failed to run queue rebalance" ,
116- "pod" , podName ,
117- "command" , cmd ,
118- "stdout" , stdout ,
119- "stderr" , stderr )
120- return err
111+ msg := "failed to run queue rebalance on pod"
112+ logger .Error (err , msg , "pod" , podName , "command" , cmd , "stdout" , stdout , "stderr" , stderr )
113+ r .Recorder .Event (rmq , corev1 .EventTypeWarning , "FailedReconcile" , fmt .Sprintf ("%s %s" , msg , podName ))
114+ return fmt .Errorf ("%s %s: %v" , msg , podName , err )
121115 }
122116 return r .deleteAnnotation (ctx , rmq , queueRebalanceAnnotation )
123117}
0 commit comments