-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proper handling of cluster-scoped resources in operators #1306
Conversation
Signed-off-by: Ken Sipe <kensipe@gmail.com>
pkg/engine/task/task_apply_test.go
Outdated
|
||
// just a small sanity check | ||
assert.True(t, got[schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "ReplicaSet"}]) | ||
assert.False(t, got[schema.GroupVersionKind{Group: "apiextensions.k8s.io", Version: "v1", Kind: "CustomResourceDefinition"}]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we test if a custom resource for both a Namespaced CRD and a Cluster scoped CRD also work here, just so we have it in the event of any regressions (and we're talking, in Kubernetes terms, about two different API servers here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean a CR (not CRD), right? Because CRDs are always cluster-scoped. CRs might be not.
tests fail... this test was added as a unit test but it looks like an integration test
|
I'm also concerned... what happens if the resource isn't in the map? |
an explicit failure with an Event would be good here - this would be the case if a CRD doesn't exist. |
Good point. currently, it will be |
what do you mean? We don't check for specific CRDs, just if GVK |
@zen-dog If the Prometheus Operator |
(or some cluster-scoped form of ServiceMonitor, that is.. so maybe something from Istio?) |
this would fail either way (independent of namespaced vs cluster-scoped) because KUDO would fail to apply an unknown resource |
Oh yeah, because nothing happens right now when no match is discovered in the GVK map. ObjectKeyFromObject happens before the actual apply though - so I suppose to bounce off of @kensipe, do we want to catch it in the path for ObjectKeyFromObject before we actually try to apply? |
should be a one-liner. I can add it. Though, there are multiple other places where we "let it run and fail" because figuring it out upfront is too much work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved the "simple fix" presented in the first commit. / cc @kensipe We'll work on a proper one in a followup PR
pkg/engine/task/task_apply.go
Outdated
func namespacedGVKResources() (map[schema.GroupVersionKind]bool, error) { | ||
namespaced := map[schema.GroupVersionKind]bool{} | ||
|
||
restCfg, err := config.GetConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should probably inject the config rather than load it here. You would have to find a good place from which to pass it in though, the most upper level for this is manager.GetConfig
in main.go
and then carry it through controller
…t out Signed-off-by: Ken Sipe <kensipe@gmail.com>
Co-authored-by: Aleksey Dukhovniy <adukhovniy@mesosphere.io> Signed-off-by: Ken Sipe <kensipe@gmail.com> Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Co-authored-by: Aleksey Dukhovniy <adukhovniy@mesosphere.io> Signed-off-by: Ken Sipe <kensipe@gmail.com> Signed-off-by: Thomas Runyon <runyontr@gmail.com>
What this PR does / why we need it:
Summary:
task_apply.go
Instances
Fixes #1288
Fixes #1265
Signed-off-by: Ken Sipe kensipe@gmail.com