Derive the phase from an authoritative read of the child runners

patchAppliedActionableRevisionStatus reads the EphemeralRunnerSet through
the uncached reader precisely because a cached read cannot be trusted
there, then derived Status.Phase from a cached list of the child runners.
The optimistic lock on the patch covers the EphemeralRunnerSet object
alone, so it could not vouch for that list, while a successful write made
the result look consistent. The list also sits inside RetryOnConflict,
where a cached read can return the same stale data on every attempt.

The ownership filter moves into the process, because resourceOwnerKey is
a client-side index on the manager's cache and the API server rejects
.metadata.controller as an unsupported field label. The predicate lives
next to the indexer so the two do not drift apart.

Add the index to the revision patch test fakes, which need it now that
the function lists children, and a test that separates the two reads:
it fails when the list goes through the cache and passes when it does
not.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Nikola Jokic
2026-09-11 11:21:07 +02:00
co-authored by Copilot App
parent bf2b89a349
commit 8befb9d8d7
4 changed files with 162 additions and 3 deletions
+14
View File
@@ -69,3 +69,17 @@ func newGroupVersionOwnerKindIndexer(ownerKind string, otherOwnerKinds ...string
return []string{owner.Name}
}
}
// isControlledBy applies the same ownership test as the resourceOwnerKey index,
// for callers that cannot use that index. It is registered on the manager's
// cache, so a read that deliberately bypasses the cache has to filter here
// instead: the API server rejects .metadata.controller as an unsupported field
// label. Keeping the predicate alongside the indexer is what stops the two
// drifting apart.
func isControlledBy(o client.Object, ownerKind, ownerName string) bool {
owner := metav1.GetControllerOfNoCopy(o)
return owner != nil &&
owner.APIVersion == v1alpha1.GroupVersion.String() &&
owner.Kind == ownerKind &&
owner.Name == ownerName
}