Skip to content
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

Ansible Operator proxy now fails requests when virtual resource can't be determined #3112

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions changelog/fragments/ansible-fail-if-cant-determine-vr.yaml
@@ -0,0 +1,11 @@
entries:
- description: >
The Ansible Operator proxy will now return a 500 if it cannot determine whether
a resource is virtual or not, instead of continuing on and skipping the cache.
This will prevent resources that should have ownerReferences injected from
being created without them, which would leave the user in a state that cannot be
recovered without manual intervention.

kind: "bugfix"

breaking: false
11 changes: 8 additions & 3 deletions pkg/ansible/proxy/inject_owner.go
Expand Up @@ -81,9 +81,14 @@ func (i *injectOwnerReferenceHandler) ServeHTTP(w http.ResponseWriter, req *http
// Determine if the resource is virtual. If it is then we should not attempt to use cache
isVR, err := i.apiResources.IsVirtualResource(k)
if err != nil {
// break here in case we can not understand if virtual resource or not
log.Error(err, "Unable to determine if virtual resource", "gvk", k)
break
// Fail if we can't determine whether it's a virtual resource or not.
// Otherwise we might create a resource without an ownerReference, which will prevent
// dependentWatches from being re-established and garbage collection from deleting the
// resource, unless a user manually adds the ownerReference.
m := "Unable to determine if virtual resource"
log.Error(err, m, "gvk", k)
http.Error(w, m, http.StatusInternalServerError)
return
}

if isVR {
Expand Down