DRA ResourceClaim controller: updated mutation cache based on events

The controller would recover eventually because it double-checks when seeing
the pod status update, but when reacting to events it recovers faster.

Kubernetes-commit: 03c34ede467ea16580beee3937f9997070421529
This commit is contained in:
Patrick Ohly
2026-06-29 11:45:25 +02:00
committed by Kubernetes Publisher
parent f199fa2ea1
commit ead00aa2cf
2 changed files with 24 additions and 0 deletions

View File

@@ -4,6 +4,23 @@ Go API changes are typically not included in the Kubernetes release notes, so
noteworthy Go API changes *may* be documented here. This is currently not
*required*, so consult the git history to see all changes.
### mutation cache: support informer events
Calling OnAddOrUpdate and OnDelete from event handlers is optional. Calling
them has the advantage that the mutation cache is updated sooner. It also fixes
incorrectly reporting a locally updated item when a) using "include adds" and
b) the updated item got deleted in the apiserver and informer cache.
Although formally a Go API break because the MutationCache interface gets
extended, in practice that interface is expected to have only the single
implementation in client-go itself, so no-one should be affected by this.
```
- ./tools/cache.MutationCache.OnAddOrUpdate: added
- ./tools/cache.MutationCache.OnDelete: added
- ./tools/cache.MutationCache.internal: added unexported method
```
### restmapper + discovery: add context-aware APIs
See [PR #129109](https://github.com/kubernetes/kubernetes/pull/129109).

View File

@@ -46,6 +46,11 @@ type MutationCache interface {
Mutation(interface{})
OnAddOrUpdate(obj runtime.Object)
OnDelete(obj runtime.Object)
// This interface is not meant to be implemented elsewhere.
// Marking it as internal enables future changes without
// triggering apidiff.
internal()
}
// ResourceVersionComparator is able to compare object versions.
@@ -356,6 +361,8 @@ func (c *mutationCache) OnDelete(obj runtime.Object) {
c.mutationCache.Add(key, t, c.ttl)
}
func (c *mutationCache) internal() {}
// etcdObjectVersioner implements versioning and extracting etcd node information
// for objects that have an embedded ObjectMeta or ListMeta field.
type etcdObjectVersioner struct{}