Add helm add repo synchonously to avoid race conditions with multiple repositories

This commit is contained in:
mseashor 2018-03-05 16:06:49 -08:00
parent 8f607b0da7
commit 72eaa2fb62
1 changed files with 4 additions and 9 deletions

View File

@ -124,19 +124,13 @@ func (state *HelmState) applyDefaultsTo(spec ReleaseSpec) ReleaseSpec {
} }
func (state *HelmState) SyncRepos(helm helmexec.Interface) []error { func (state *HelmState) SyncRepos(helm helmexec.Interface) []error {
var wg sync.WaitGroup
errs := []error{} errs := []error{}
for _, repo := range state.Repositories { for _, repo := range state.Repositories {
wg.Add(1) if err := helm.AddRepo(repo.Name, repo.URL); err != nil {
go func(wg *sync.WaitGroup, name, url string) { errs = append(errs, err)
if err := helm.AddRepo(name, url); err != nil { }
errs = append(errs, err)
}
wg.Done()
}(&wg, repo.Name, repo.URL)
} }
wg.Wait()
if len(errs) != 0 { if len(errs) != 0 {
return errs return errs
@ -157,6 +151,7 @@ func (state *HelmState) SyncReleases(helm helmexec.Interface, additonalValues []
if workerLimit < 1 { if workerLimit < 1 {
workerLimit = len(state.Releases) workerLimit = len(state.Releases)
} }
for w := 1; w <= workerLimit; w++ { for w := 1; w <= workerLimit; w++ {
go func() { go func() {
for release := range jobQueue { for release := range jobQueue {