@@ -110,19 +110,12 @@ func (r *RabbitmqClusterReconciler) Reconcile(req ctrl.Request) (ctrl.Result, er
110
110
return ctrl.Result {}, err
111
111
}
112
112
113
- childResources , err := r .getChildResources (ctx , * rabbitmqCluster )
113
+ requeueAfter , err := r .updateStatus (ctx , rabbitmqCluster )
114
114
if err != nil {
115
115
return ctrl.Result {}, err
116
116
}
117
-
118
- oldConditions := make ([]status.RabbitmqClusterCondition , len (rabbitmqCluster .Status .Conditions ))
119
- copy (oldConditions , rabbitmqCluster .Status .Conditions )
120
- rabbitmqCluster .Status .SetConditions (childResources )
121
-
122
- if ! reflect .DeepEqual (rabbitmqCluster .Status .Conditions , oldConditions ) {
123
- if err = r .Status ().Update (ctx , rabbitmqCluster ); err != nil {
124
- return ctrl.Result {}, err
125
- }
117
+ if requeueAfter > 0 {
118
+ return ctrl.Result {RequeueAfter : requeueAfter }, nil
126
119
}
127
120
128
121
sts , err := r .statefulSet (ctx , rabbitmqCluster )
@@ -186,7 +179,7 @@ func (r *RabbitmqClusterReconciler) Reconcile(req ctrl.Request) (ctrl.Result, er
186
179
}
187
180
}
188
181
189
- requeueAfter , err : = r .restartStatefulSetIfNeeded (ctx , rabbitmqCluster )
182
+ requeueAfter , err = r .restartStatefulSetIfNeeded (ctx , rabbitmqCluster )
190
183
if err != nil {
191
184
return ctrl.Result {}, err
192
185
}
@@ -252,7 +245,31 @@ func (r *RabbitmqClusterReconciler) logAndRecordOperationResult(rmq runtime.Obje
252
245
}
253
246
}
254
247
255
- func (r * RabbitmqClusterReconciler ) getChildResources (ctx context.Context , rmq rabbitmqv1beta1.RabbitmqCluster ) ([]runtime.Object , error ) {
248
+ func (r * RabbitmqClusterReconciler ) updateStatus (ctx context.Context , rmq * rabbitmqv1beta1.RabbitmqCluster ) (time.Duration , error ) {
249
+ childResources , err := r .getChildResources (ctx , rmq )
250
+ if err != nil {
251
+ return 0 , err
252
+ }
253
+
254
+ oldConditions := make ([]status.RabbitmqClusterCondition , len (rmq .Status .Conditions ))
255
+ copy (oldConditions , rmq .Status .Conditions )
256
+ rmq .Status .SetConditions (childResources )
257
+
258
+ if ! reflect .DeepEqual (rmq .Status .Conditions , oldConditions ) {
259
+ if err = r .Status ().Update (ctx , rmq ); err != nil {
260
+ if errors .IsConflict (err ) {
261
+ r .Log .Info ("failed to update status because of conflict; requeueing..." ,
262
+ "namespace" , rmq .Namespace ,
263
+ "name" , rmq .Name )
264
+ return 2 * time .Second , nil
265
+ }
266
+ return 0 , err
267
+ }
268
+ }
269
+ return 0 , nil
270
+ }
271
+
272
+ func (r * RabbitmqClusterReconciler ) getChildResources (ctx context.Context , rmq * rabbitmqv1beta1.RabbitmqCluster ) ([]runtime.Object , error ) {
256
273
sts := & appsv1.StatefulSet {}
257
274
endPoints := & corev1.Endpoints {}
258
275
0 commit comments