runtime/kubernetes: ignore namespace already exists errors (#1852)
Co-authored-by: Asim Aslam <asim@aslam.me>
This commit is contained in:
parent
bcc890e47c
commit
0d860c53a6
@ -67,6 +67,12 @@ func (k *kubernetes) createNamespace(namespace string) error {
|
|||||||
ns := client.Namespace{Metadata: &client.Metadata{Name: namespace}}
|
ns := client.Namespace{Metadata: &client.Metadata{Name: namespace}}
|
||||||
err := k.client.Create(&client.Resource{Kind: "namespace", Value: ns})
|
err := k.client.Create(&client.Resource{Kind: "namespace", Value: ns})
|
||||||
|
|
||||||
|
// ignore err already exists
|
||||||
|
if err != nil && strings.Contains(err.Error(), "already exists") {
|
||||||
|
logger.Debugf("Ignoring ErrAlreadyExists for namespace %v: %v", namespace, err)
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
|
||||||
// add to cache
|
// add to cache
|
||||||
if err == nil && k.namespaces != nil {
|
if err == nil && k.namespaces != nil {
|
||||||
k.namespaces = append(k.namespaces, ns)
|
k.namespaces = append(k.namespaces, ns)
|
||||||
|
Loading…
Reference in New Issue
Block a user