Skip to content

Commit f3fa969

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 f310145 commit f3fa969

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
@@ -169,7 +169,7 @@ func (r *reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
169169
}
170170
oldStatus := co.Status.DeepCopy()
171171

172-
state, err := r.getOperatorState(ingressNamespace, canaryNamespace, co)
172+
state, err := r.getOperatorState(ctx, ingressNamespace, canaryNamespace, co)
173173
if err != nil {
174174
return reconcile.Result{}, fmt.Errorf("failed to get operator state: %v", err)
175175
}
@@ -306,11 +306,11 @@ type operatorState struct {
306306

307307
// getOperatorState gets and returns the resources necessary to compute the
308308
// operator's current state.
309-
func (r *reconciler) getOperatorState(ingressNamespace, canaryNamespace string, co *configv1.ClusterOperator) (operatorState, error) {
309+
func (r *reconciler) getOperatorState(ctx context.Context, ingressNamespace, canaryNamespace string, co *configv1.ClusterOperator) (operatorState, error) {
310310
state := operatorState{}
311311

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

321321
ns = &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: canaryNamespace}}
322-
if err := r.client.Get(context.TODO(), types.NamespacedName{Name: canaryNamespace}, ns); err != nil {
322+
if err := r.client.Get(ctx, types.NamespacedName{Name: canaryNamespace}, ns); err != nil {
323323
if !errors.IsNotFound(err) {
324324
return state, fmt.Errorf("failed to get namespace %q: %v", canaryNamespace, err)
325325
}
@@ -328,7 +328,7 @@ func (r *reconciler) getOperatorState(ingressNamespace, canaryNamespace string,
328328
}
329329

330330
ingressList := &operatorv1.IngressControllerList{}
331-
if err := r.cache.List(context.TODO(), ingressList, client.InNamespace(r.config.Namespace)); err != nil {
331+
if err := r.cache.List(ctx, ingressList, client.InNamespace(r.config.Namespace)); err != nil {
332332
return state, fmt.Errorf("failed to list ingresscontrollers in %q: %v", r.config.Namespace, err)
333333
} else {
334334
state.IngressControllers = ingressList.Items
@@ -337,7 +337,7 @@ func (r *reconciler) getOperatorState(ingressNamespace, canaryNamespace string,
337337
if r.config.GatewayAPIEnabled {
338338
var subscription operatorsv1alpha1.Subscription
339339
subscriptionName := operatorcontroller.ServiceMeshOperatorSubscriptionName()
340-
if err := r.cache.Get(context.TODO(), subscriptionName, &subscription); err != nil {
340+
if err := r.cache.Get(ctx, subscriptionName, &subscription); err != nil {
341341
if !errors.IsNotFound(err) {
342342
return state, fmt.Errorf("failed to get subscription %q: %v", subscriptionName, err)
343343
}

0 commit comments

Comments
 (0)