Unverified Commit a660b189 authored by Matthew Fisher's avatar Matthew Fisher Committed by GitHub

Merge pull request #4135 from…

Merge pull request #4135 from mattjmcnaughton/mattjmcnaughton/4086-fix-concurrency-issues-with-helm-install

Fix concurrency issues with helm install
parents daeb4583 53c8e9b6
......@@ -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
}
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment