Skip to content

Commit

Permalink
Fix race while running helm dep build on local chart
Browse files Browse the repository at this point in the history
Resolves #1438
  • Loading branch information
mumoshu committed Aug 28, 2020
1 parent 14e2b9e commit e2cb3f6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ type HelmState struct {
runner helmexec.Runner
valsRuntime vals.Evaluator

depBuiltChartsMu sync.Mutex
depBuiltCharts map[string]bool

// If set to "Error", return an error when a subhelmfile points to a
// non-existent path. The default behavior is to print a warning. Note the
// differing default compared to other MissingFileHandlers.
Expand Down Expand Up @@ -924,7 +927,19 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre
// a broken remote chart won't completely block their job.
chartPath = normalizeChart(st.basePath, chartPath)

if !opts.SkipRepos {
var doBuildDeps bool

(&st.depBuiltChartsMu).Lock()
if st.depBuiltCharts == nil {
st.depBuiltCharts = map[string]bool{}
}
if !st.depBuiltCharts[chartPath] {
st.depBuiltCharts[chartPath] = true
doBuildDeps = true
}
(&st.depBuiltChartsMu).Unlock()

if !opts.SkipRepos && doBuildDeps {
if err := helm.BuildDeps(release.Name, chartPath); err != nil {
if chartFetchedByGoGetter {
diagnostic = fmt.Sprintf(
Expand Down

0 comments on commit e2cb3f6

Please sign in to comment.