Merge pull request #135000 from p0lyn0mial/upstream-watchlist-unsupported-wl-semantics-trackers

k8s.io/client-go/testing/fixture: does not support WatchList semantics
This commit is contained in:
Kubernetes Prow Robot
2025-10-31 02:52:11 -07:00
committed by GitHub
2 changed files with 23 additions and 0 deletions

View File

@@ -511,6 +511,17 @@ func (t *tracker) Apply(gvr schema.GroupVersionResource, applyConfiguration runt
return t.add(gvr, obj, ns, true)
}
// IsWatchListSemanticsUnSupported informs the reflector that this client
// doesn't support WatchList semantics.
//
// This is a synthetic method whose sole purpose is to satisfy the optional
// interface check performed by the reflector.
// Returning true signals that WatchList can NOT be used.
// No additional logic is implemented here.
func (t *tracker) IsWatchListSemanticsUnSupported() bool {
return true
}
func (t *tracker) getWatches(gvr schema.GroupVersionResource, ns string) []*watch.RaceFreeFakeWatcher {
watches := []*watch.RaceFreeFakeWatcher{}
if t.watchers[gvr] != nil {

View File

@@ -39,6 +39,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/managedfields"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/util/watchlist"
"k8s.io/utils/ptr"
)
@@ -740,3 +741,14 @@ func TestManagedFielsdObjectTrackerWithUnstructured(t *testing.T) {
unstructured.RemoveNestedField(cmActual.Object, "metadata", "managedFields")
require.Empty(t, cmp.Diff(cmOriginal, cmActual))
}
func TestDoesClientSupportWatchListSemantics(t *testing.T) {
scheme := runtime.NewScheme()
codecs := serializer.NewCodecFactory(scheme)
target := NewObjectTracker(scheme, codecs.UniversalDecoder())
if !watchlist.DoesClientNotSupportWatchListSemantics(target) {
t.Fatalf("ObjectTracker should NOT support WatchList semantics")
}
}