Skip to content

Commit 751bb76

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 fb548fc commit 751bb76

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

186-
state, err := r.getOperatorState(ingressNamespace, canaryNamespace, co)
186+
state, err := r.getOperatorState(ctx, ingressNamespace, canaryNamespace, co)
187187
if err != nil {
188188
return reconcile.Result{}, fmt.Errorf("failed to get operator state: %v", err)
189189
}
@@ -320,11 +320,11 @@ type operatorState struct {
320320

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

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

335335
ns = &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: canaryNamespace}}
336-
if err := r.client.Get(context.TODO(), types.NamespacedName{Name: canaryNamespace}, ns); err != nil {
336+
if err := r.client.Get(ctx, types.NamespacedName{Name: canaryNamespace}, ns); err != nil {
337337
if !errors.IsNotFound(err) {
338338
return state, fmt.Errorf("failed to get namespace %q: %v", canaryNamespace, err)
339339
}
@@ -342,7 +342,7 @@ func (r *reconciler) getOperatorState(ingressNamespace, canaryNamespace string,
342342
}
343343

344344
ingressList := &operatorv1.IngressControllerList{}
345-
if err := r.cache.List(context.TODO(), ingressList, client.InNamespace(r.config.Namespace)); err != nil {
345+
if err := r.cache.List(ctx, ingressList, client.InNamespace(r.config.Namespace)); err != nil {
346346
return state, fmt.Errorf("failed to list ingresscontrollers in %q: %v", r.config.Namespace, err)
347347
} else {
348348
state.IngressControllers = ingressList.Items
@@ -352,7 +352,7 @@ func (r *reconciler) getOperatorState(ingressNamespace, canaryNamespace string,
352352
if r.config.MarketplaceEnabled && r.config.OperatorLifecycleManagerEnabled {
353353
var subscription operatorsv1alpha1.Subscription
354354
subscriptionName := operatorcontroller.ServiceMeshOperatorSubscriptionName()
355-
if err := r.cache.Get(context.TODO(), subscriptionName, &subscription); err != nil {
355+
if err := r.cache.Get(ctx, subscriptionName, &subscription); err != nil {
356356
if !errors.IsNotFound(err) {
357357
return state, fmt.Errorf("failed to get subscription %q: %v", subscriptionName, err)
358358
}

0 commit comments

Comments
 (0)