Merge pull request #106121 from wojtek-t/pf_watch_10

P&F fix watch tracker bug
This commit is contained in:
Kubernetes Prow Robot
2021-11-03 10:43:34 -07:00
committed by GitHub
2 changed files with 8 additions and 2 deletions

View File

@@ -175,7 +175,7 @@ func (w *watchTracker) updateIndexLocked(identifier *watchIdentifier, index *ind
// This seem to be true in almost all production clusters, which makes
// it a reasonable first step simplification to unblock progres on it.
if index.value == unsetValue || index.value == "" {
w.watchCount[*identifier]++
w.watchCount[*identifier] += incr
}
}
}

View File

@@ -91,6 +91,11 @@ func TestRegisterWatch(t *testing.T) {
request: httpRequest("GET", "/apis/group/v1/namespaces/foo/pods", "watch=true&fieldSelector=metadata.name=mypod"),
expected: newWatchIdentifier("group", "pods", "foo", "mypod"),
},
{
name: "watch indexed object",
request: httpRequest("GET", "/apis/group/v1/namespaces/foo/pods", "watch=true&fieldSelector=spec.nodeName="),
expected: newWatchIdentifier("group", "pods", "foo", ""),
},
}
requestInfoFactory := &request.RequestInfoFactory{
@@ -101,6 +106,7 @@ func TestRegisterWatch(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
watchTracker := &watchTracker{
indexes: getBuiltinIndexes(),
watchCount: make(map[watchIdentifier]int),
}
@@ -265,7 +271,7 @@ func TestGetInterestedWatchCountWithIndex(t *testing.T) {
httpRequest("GET", "api/v1/pods", "watch=true"),
httpRequest("GET", "api/v1/namespaces/foo/pods", "watch=true"),
httpRequest("GET", "api/v1/namespaces/foo/pods", "watch=true&fieldSelector=metadata.name=mypod"),
httpRequest("GET", "api/v1/namespaces/foo/pods", "watch=true&fieldSelector=spec.nodeName"),
httpRequest("GET", "api/v1/namespaces/foo/pods", "watch=true&fieldSelector=spec.nodeName="),
// The watches below will be ignored due to index.
httpRequest("GET", "api/v1/namespaces/foo/pods", "watch=true&fieldSelector=spec.nodeName=node1"),
httpRequest("GET", "api/v1/namespaces/foo/pods", "watch=true&fieldSelector=spec.nodeName=node2"),