runtime/kubernetes: ignore namespace already exists errors (#1852)

Co-authored-by: Asim Aslam <asim@aslam.me>
This commit is contained in:
ben-toogood 2020-07-18 11:12:05 +01:00 committed by GitHub
parent bcc890e47c
commit 0d860c53a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,6 +67,12 @@ func (k *kubernetes) createNamespace(namespace string) error {
ns := client.Namespace{Metadata: &client.Metadata{Name: namespace}}
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
if err == nil && k.namespaces != nil {
k.namespaces = append(k.namespaces, ns)