kubernetes: Improve namespace usage (#4767)

* Use GetByKey instead of List in GetNamespaceByName.
* Add ToNamespace to reduce memory for namespace cache.

Signed-off-by: Mat Lowery <mlowery@ebay.com>
This commit is contained in:
Mat Lowery 2021-07-29 21:27:25 -06:00 committed by GitHub
parent 8ff7c4b834
commit 9d5b8cd13d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 100 additions and 47 deletions

View file

@ -782,16 +782,14 @@ func (APIConnServeTest) GetNodeByName(ctx context.Context, name string) (*api.No
}, nil
}
func (APIConnServeTest) GetNamespaceByName(name string) (*api.Namespace, error) {
func (APIConnServeTest) GetNamespaceByName(name string) (*object.Namespace, error) {
if name == "pod-nons" { // handler_pod_verified_test.go uses this for non-existent namespace.
return &api.Namespace{}, nil
return nil, fmt.Errorf("namespace not found")
}
if name == "nsnoexist" {
return nil, fmt.Errorf("namespace not found")
}
return &api.Namespace{
ObjectMeta: meta.ObjectMeta{
Name: name,
},
return &object.Namespace{
Name: name,
}, nil
}