Skip to content

Commit 58e9a47

Browse files
committed
getOperatorState: Add context parameter
* pkg/operator/controller/status/controller.go (Reconcile): Pass ctx to getOperatorState. * pkg/operator/controller/status/controller.go (getOperatorState): Add a parameter for ctx, and use it instead of context.TODO().
1 parent fb875f1 commit 58e9a47

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pkg/operator/controller/status/controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (r *reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
161161
}
162162
oldStatus := co.Status.DeepCopy()
163163

164-
state, err := r.getOperatorState(ingressNamespace, canaryNamespace)
164+
state, err := r.getOperatorState(ctx, ingressNamespace, canaryNamespace)
165165
if err != nil {
166166
return reconcile.Result{}, fmt.Errorf("failed to get operator state: %v", err)
167167
}
@@ -299,11 +299,11 @@ type operatorState struct {
299299

300300
// getOperatorState gets and returns the resources necessary to compute the
301301
// operator's current state.
302-
func (r *reconciler) getOperatorState(ingressNamespace, canaryNamespace string) (operatorState, error) {
302+
func (r *reconciler) getOperatorState(ctx context.Context, ingressNamespace, canaryNamespace string) (operatorState, error) {
303303
state := operatorState{}
304304

305305
ns := &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: ingressNamespace}}
306-
if err := r.client.Get(context.TODO(), types.NamespacedName{Name: ingressNamespace}, ns); err != nil {
306+
if err := r.client.Get(ctx, types.NamespacedName{Name: ingressNamespace}, ns); err != nil {
307307
if !errors.IsNotFound(err) {
308308
return state, fmt.Errorf("failed to get namespace %q: %v", ingressNamespace, err)
309309
}
@@ -312,7 +312,7 @@ func (r *reconciler) getOperatorState(ingressNamespace, canaryNamespace string)
312312
}
313313

314314
ns = &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: canaryNamespace}}
315-
if err := r.client.Get(context.TODO(), types.NamespacedName{Name: canaryNamespace}, ns); err != nil {
315+
if err := r.client.Get(ctx, types.NamespacedName{Name: canaryNamespace}, ns); err != nil {
316316
if !errors.IsNotFound(err) {
317317
return state, fmt.Errorf("failed to get namespace %q: %v", canaryNamespace, err)
318318
}
@@ -321,7 +321,7 @@ func (r *reconciler) getOperatorState(ingressNamespace, canaryNamespace string)
321321
}
322322

323323
ingressList := &operatorv1.IngressControllerList{}
324-
if err := r.cache.List(context.TODO(), ingressList, client.InNamespace(r.config.Namespace)); err != nil {
324+
if err := r.cache.List(ctx, ingressList, client.InNamespace(r.config.Namespace)); err != nil {
325325
return state, fmt.Errorf("failed to list ingresscontrollers in %q: %v", r.config.Namespace, err)
326326
} else {
327327
state.IngressControllers = ingressList.Items
@@ -330,7 +330,7 @@ func (r *reconciler) getOperatorState(ingressNamespace, canaryNamespace string)
330330
if r.config.GatewayAPIEnabled {
331331
var subscription operatorsv1alpha1.Subscription
332332
subscriptionName := operatorcontroller.ServiceMeshOperatorSubscriptionName()
333-
if err := r.cache.Get(context.TODO(), subscriptionName, &subscription); err != nil {
333+
if err := r.cache.Get(ctx, subscriptionName, &subscription); err != nil {
334334
if !errors.IsNotFound(err) {
335335
return state, fmt.Errorf("failed to get subscription %q: %v", subscriptionName, err)
336336
}

0 commit comments

Comments
 (0)