mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #106121 from wojtek-t/pf_watch_10
P&F fix watch tracker bug
This commit is contained in:
commit
0b8ac0c0fc
@ -175,7 +175,7 @@ func (w *watchTracker) updateIndexLocked(identifier *watchIdentifier, index *ind
|
|||||||
// This seem to be true in almost all production clusters, which makes
|
// This seem to be true in almost all production clusters, which makes
|
||||||
// it a reasonable first step simplification to unblock progres on it.
|
// it a reasonable first step simplification to unblock progres on it.
|
||||||
if index.value == unsetValue || index.value == "" {
|
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"),
|
request: httpRequest("GET", "/apis/group/v1/namespaces/foo/pods", "watch=true&fieldSelector=metadata.name=mypod"),
|
||||||
expected: newWatchIdentifier("group", "pods", "foo", "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{
|
requestInfoFactory := &request.RequestInfoFactory{
|
||||||
@ -101,6 +106,7 @@ func TestRegisterWatch(t *testing.T) {
|
|||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
t.Run(testCase.name, func(t *testing.T) {
|
t.Run(testCase.name, func(t *testing.T) {
|
||||||
watchTracker := &watchTracker{
|
watchTracker := &watchTracker{
|
||||||
|
indexes: getBuiltinIndexes(),
|
||||||
watchCount: make(map[watchIdentifier]int),
|
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/pods", "watch=true"),
|
||||||
httpRequest("GET", "api/v1/namespaces/foo/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=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.
|
// 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=node1"),
|
||||||
httpRequest("GET", "api/v1/namespaces/foo/pods", "watch=true&fieldSelector=spec.nodeName=node2"),
|
httpRequest("GET", "api/v1/namespaces/foo/pods", "watch=true&fieldSelector=spec.nodeName=node2"),
|
||||||
|
Loading…
Reference in New Issue
Block a user