Handle support for secondary resource provided by CRD when not present at Operator start #6841
Labels
language/go
Issue is related to a Go operator project
lifecycle/stale
Denotes an issue or PR has remained open with no activity and has become stale.
Type of question
Best practices
How to implement a specific feature
Question
What did you do?
Our project needs to account for the presence/absence of various CRDs, and, depending upon the settings on our Operator's primary resource, the controller needs to handle those secondary resources. Examples include:
As far as what we did, we wrote functions similar to this response to a previous issue here for the first and second bullets, but, for the third, we used a check of the
APIResources
listed for the GV to see if that GVK was registered. Using those, we have the following in theinit
in our main.go:In the
SetupWithManager
function for the controller, we have the following:What did you expect to see?
Ideally, if someone ended up installing the CRDs that this Operator would have skipped loading support for here, the Operator could detect this and load the missing GVs into its scheme. Alternatively, if there's a way for them to always be loaded, but not lead to the Operator exiting when it's not able to watch for them at the start, I would be happy with that as well.
What did you see instead? Under which circumstances?
So far, it seems like by adding them to the scheme in our main.go's
init
, the Manager will end up trying to watch for them, leading to exits due to failed watches. Makes sense - the resources it's trying to look for are not supported yet. I'd prefer a solution that doesn't mandate a Pod restart when the new APIs become supported.Environment
Operator type:
/language go
Kubernetes cluster type:
Vanilla and OpenShift
$ operator-sdk version
$ go version
(if language is Go)$ kubectl version
Additional context
The text was updated successfully, but these errors were encountered: