openshift / vertical-pod-autoscaler-operator

An Operator for running the Vertical Pod Autoscaler on OpenShift
Apache License 2.0
27 stars 30 forks source link

Fix operator start-up sequence: wait for manager start before using API client #68

Closed joelsmith closed 3 years ago

joelsmith commented 3 years ago

This fixes the problem where r.client.Get() fails because the manager hasn't started (via it's Start() method). Since the reconciler interface doesn't have any initialization hook called after start, this patch uses a background goroutine to wait for the manager to start before attempting to check whether a CR exists.

This resolves the crash loop backoff with error:

verticalpodautoscaler_controller.go:201] Error reading VerticalPodAutoscalerController: the cache is not started, can not read objects
main.go:30] Failed to create operator: failed to add controllers: the cache is not started, can not read objects

This error showed up after the rebase PR #65 when we pulled in an updated controller runtime.

wangchen615 commented 3 years ago

/lgtm

openshift-ci-robot commented 3 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: joelsmith, wangchen615

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/openshift/vertical-pod-autoscaler-operator/blob/master/OWNERS)~~ [joelsmith,wangchen615] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment