Skip to content

Commit 494969a

Browse files
authored
Ansible Operator proxy now fails requests when virtual resource can't be determined (#3112)
* proxy now returns a 500 when we fail to determine if a resource is virtual * Add changelog
1 parent 69e47c2 commit 494969a

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
entries:
2+
- description: >
3+
The Ansible Operator proxy will now return a 500 if it cannot determine whether
4+
a resource is virtual or not, instead of continuing on and skipping the cache.
5+
This will prevent resources that should have ownerReferences injected from
6+
being created without them, which would leave the user in a state that cannot be
7+
recovered without manual intervention.
8+
9+
kind: "bugfix"
10+
11+
breaking: false

pkg/ansible/proxy/inject_owner.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,14 @@ func (i *injectOwnerReferenceHandler) ServeHTTP(w http.ResponseWriter, req *http
8181
// Determine if the resource is virtual. If it is then we should not attempt to use cache
8282
isVR, err := i.apiResources.IsVirtualResource(k)
8383
if err != nil {
84-
// break here in case we can not understand if virtual resource or not
85-
log.Error(err, "Unable to determine if virtual resource", "gvk", k)
86-
break
84+
// Fail if we can't determine whether it's a virtual resource or not.
85+
// Otherwise we might create a resource without an ownerReference, which will prevent
86+
// dependentWatches from being re-established and garbage collection from deleting the
87+
// resource, unless a user manually adds the ownerReference.
88+
m := "Unable to determine if virtual resource"
89+
log.Error(err, m, "gvk", k)
90+
http.Error(w, m, http.StatusInternalServerError)
91+
return
8792
}
8893

8994
if isVR {

0 commit comments

Comments
 (0)