mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-21 12:50:02 +02:00
fix: fatal error: concurrent map read and map write on concurrency > 1 (#742)
This is a revised version of https://github.com/roboll/helmfile/commit/41e44f74a37ebca0394d9ec4546c27208f8a1adf, which doesn't make CI angry and a more straight-forward(yet smelling) implementation Fixes #737
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/roboll/helmfile/pkg/environment"
|
||||
"github.com/roboll/helmfile/pkg/event"
|
||||
@@ -248,6 +249,8 @@ func (st *HelmState) prepareSyncReleases(helm helmexec.Interface, additionalValu
|
||||
res := []syncPrepareResult{}
|
||||
errs := []error{}
|
||||
|
||||
mut := sync.Mutex{}
|
||||
|
||||
st.scatterGather(
|
||||
concurrency,
|
||||
numReleases,
|
||||
@@ -272,7 +275,11 @@ func (st *HelmState) prepareSyncReleases(helm helmexec.Interface, additionalValu
|
||||
continue
|
||||
}
|
||||
|
||||
// TODO We need a long-term fix for this :)
|
||||
// See https://github.com/roboll/helmfile/issues/737
|
||||
mut.Lock()
|
||||
flags, flagsErr := st.flagsForUpgrade(helm, release, workerIndex)
|
||||
mut.Unlock()
|
||||
if flagsErr != nil {
|
||||
results <- syncPrepareResult{errors: []*ReleaseError{newReleaseError(release, flagsErr)}}
|
||||
continue
|
||||
@@ -683,6 +690,8 @@ func (st *HelmState) prepareDiffReleases(helm helmexec.Interface, additionalValu
|
||||
rs := []diffPrepareResult{}
|
||||
errs := []error{}
|
||||
|
||||
mut := sync.Mutex{}
|
||||
|
||||
st.scatterGather(
|
||||
concurrency,
|
||||
numReleases,
|
||||
@@ -698,7 +707,11 @@ func (st *HelmState) prepareDiffReleases(helm helmexec.Interface, additionalValu
|
||||
|
||||
st.applyDefaultsTo(release)
|
||||
|
||||
// TODO We need a long-term fix for this :)
|
||||
// See https://github.com/roboll/helmfile/issues/737
|
||||
mut.Lock()
|
||||
flags, err := st.flagsForDiff(helm, release, workerIndex)
|
||||
mut.Unlock()
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user