Skip to content

Commit 008f9c7

Browse files
committed
Add context.Context to method Reconcile()
- Reconciler interface has changed in controller runtime 0.7; Reconcile() takes an additional context.Context, which can be used throughout Reconcile() function. - CreateOrUpdate() needs to in client.Client explicitly
1 parent 15d36f2 commit 008f9c7

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

controllers/rabbitmqcluster_controller.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ type RabbitmqClusterReconciler struct {
8181
// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=roles,verbs=get;list;watch;create;update
8282
// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=get;list;watch;create;update
8383

84-
func (r *RabbitmqClusterReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
85-
ctx := context.Background()
84+
func (r *RabbitmqClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
8685
logger := r.Log
8786

8887
rabbitmqCluster, err := r.getRabbitmqCluster(ctx, req.NamespacedName)
@@ -172,7 +171,7 @@ func (r *RabbitmqClusterReconciler) Reconcile(req ctrl.Request) (ctrl.Result, er
172171
var operationResult controllerutil.OperationResult
173172
err = clientretry.RetryOnConflict(clientretry.DefaultRetry, func() error {
174173
var apiError error
175-
operationResult, apiError = controllerutil.CreateOrUpdate(ctx, r, resource, func() error {
174+
operationResult, apiError = controllerutil.CreateOrUpdate(ctx, r.Client, resource, func() error {
176175
return builder.Update(resource)
177176
})
178177
return apiError

0 commit comments

Comments
 (0)