fix: use finer-grained locking when listing releases for diff (#1343)

`isReleaseInstalled` will call `helm list` which can take a bit of time.
in order to allow parallelism, we need to use a finer mutex lock.

Signed-off-by: Steven Davidovitz <steven.davidovitz@dominodatalab.com>
This commit is contained in:
Steven Davidovitz 2024-02-13 15:56:16 -08:00 committed by GitHub
parent 99a4d8b62f
commit a027b23698
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 5 deletions

View File

@ -1772,16 +1772,17 @@ func (st *HelmState) prepareDiffReleases(helm helmexec.Interface, additionalValu
o.Apply(opt) o.Apply(opt)
} }
mu := &sync.Mutex{} mu := &sync.RWMutex{}
installedReleases := map[string]bool{} installedReleases := map[string]bool{}
isInstalled := func(r *ReleaseSpec) bool { isInstalled := func(r *ReleaseSpec) bool {
mu.Lock()
defer mu.Unlock()
id := ReleaseToID(r) id := ReleaseToID(r)
if v, ok := installedReleases[id]; ok { mu.RLock()
v, ok := installedReleases[id]
mu.RUnlock()
if ok {
return v return v
} }
@ -1789,7 +1790,9 @@ func (st *HelmState) prepareDiffReleases(helm helmexec.Interface, additionalValu
if err != nil { if err != nil {
st.logger.Warnf("confirming if the release is already installed or not: %v", err) st.logger.Warnf("confirming if the release is already installed or not: %v", err)
} else { } else {
mu.Lock()
installedReleases[id] = v installedReleases[id] = v
mu.Unlock()
} }
return v return v