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
|
@ -52,7 +52,8 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
emptyFunc = func(bool) {}
|
||||
emptyFunc = func(bool) {}
|
||||
coreNamespaceResource = schema.GroupResource{Group: "", Resource: "namespaces"}
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -559,6 +560,12 @@ func (c *Cacher) Watch(ctx context.Context, key string, opts storage.ListOptions
|
|||
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
|
||||
if c.indexedTrigger != nil {
|
||||
for _, field := range pred.IndexFields {
|
||||
|
|
Loading…
Reference in New Issue