apiserver: fix watch namespace
For request like '/api/v1/watch/namespaces/*', don't set scope.namespace. Because the func `addWatcher` add a watcher to allWatchers with the value `scope.namespace` not empty. But the function `dispatchEvent` dispatch event with an empty namespace. Signed-off-by: xyz-li <hui0787411@163.com> Kubernetes-commit: 818fabe37b3fd7cebe36a43244120388977373cd
This commit is contained in:
parent
253c97b2e8
commit
e5e53b7acc
|
|
@ -53,6 +53,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
emptyFunc = func(bool) {}
|
emptyFunc = func(bool) {}
|
||||||
|
coreNamespaceResource = schema.GroupResource{Group: "", Resource: "namespaces"}
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -559,6 +560,12 @@ func (c *Cacher) Watch(ctx context.Context, key string, opts storage.ListOptions
|
||||||
scope.name = selectorName
|
scope.name = selectorName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for request like '/api/v1/watch/namespaces/*', set scope.namespace to empty.
|
||||||
|
// namespaces don't populate metadata.namespace in ObjFields.
|
||||||
|
if c.groupResource == coreNamespaceResource && len(scope.namespace) > 0 && scope.namespace == scope.name {
|
||||||
|
scope.namespace = ""
|
||||||
|
}
|
||||||
|
|
||||||
triggerValue, triggerSupported := "", false
|
triggerValue, triggerSupported := "", false
|
||||||
if c.indexedTrigger != nil {
|
if c.indexedTrigger != nil {
|
||||||
for _, field := range pred.IndexFields {
|
for _, field := range pred.IndexFields {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue