P&F fix watch tracker bug
Kubernetes-commit: b1d0fde370ae409ff028c557c6a60ff69491e499
This commit is contained in:
parent
89d2b256c3
commit
64f47d35c4
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"),
|
||||
|
|
Loading…
Reference in New Issue