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

Fix concurrency issues with helm install
pull/3438/merge
Matthew Fisher 7 years ago committed by GitHub
commit a660b18987
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

Loading…
Cancel
Save