diff --git a/pkg/kube/namespace.go b/pkg/kube/namespace.go index 9d2793d87..6547e4abc 100644 --- a/pkg/kube/namespace.go +++ b/pkg/kube/namespace.go @@ -40,7 +40,16 @@ func getNamespace(client internalclientset.Interface, namespace string) (*core.N func ensureNamespace(client internalclientset.Interface, namespace string) error { _, err := getNamespace(client, namespace) if err != nil && errors.IsNotFound(err) { - return createNamespace(client, namespace) + err = createNamespace(client, namespace) + + // If multiple commands which run `ensureNamespace` are run in + // parallel, then protect against the race condition in which + // the namespace did not exist when `getNamespace` was executed, + // but did exist when `createNamespace` was executed. If that + // happens, we can just proceed as normal. + if errors.IsAlreadyExists(err) { + return nil + } } return err } diff --git a/pkg/tiller/environment/environment.go b/pkg/tiller/environment/environment.go index 366fdf522..18518dfc1 100644 --- a/pkg/tiller/environment/environment.go +++ b/pkg/tiller/environment/environment.go @@ -98,8 +98,6 @@ type Engine interface { type KubeClient interface { // Create creates one or more resources. // - // namespace must contain a valid existing namespace. - // // reader must contain a YAML stream (one or more YAML documents separated // by "\n---\n"). Create(namespace string, reader io.Reader, timeout int64, shouldWait bool) error