From adeb4ca3d974936349f1980db3ac5599bac8611e Mon Sep 17 00:00:00 2001 From: Suleiman Dibirov Date: Sun, 16 Jun 2024 16:52:05 +0300 Subject: [PATCH 1/2] fix(dependencyBuild): prevent race condition in concurrent helm dependency Signed-off-by: Suleiman Dibirov --- pkg/downloader/manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 68c9c6e00..d5340575d 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -246,7 +246,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { } destPath := filepath.Join(m.ChartPath, "charts") - tmpPath := filepath.Join(m.ChartPath, "tmpcharts") + tmpPath := filepath.Join(m.ChartPath, fmt.Sprintf("tmpcharts-%d", os.Getpid())) // Check if 'charts' directory is not actually a directory. If it does not exist, create it. if fi, err := os.Stat(destPath); err == nil { From 4d25dd3d8e403496065a130da92787f9fb175f0e Mon Sep 17 00:00:00 2001 From: Suleiman Dibirov Date: Tue, 18 Jun 2024 07:11:45 +0300 Subject: [PATCH 2/2] fixed dependency_update_test.go Signed-off-by: Suleiman Dibirov --- cmd/helm/dependency_update_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/helm/dependency_update_test.go b/cmd/helm/dependency_update_test.go index 967786b9a..1a1e0468f 100644 --- a/cmd/helm/dependency_update_test.go +++ b/cmd/helm/dependency_update_test.go @@ -200,8 +200,9 @@ func TestDependencyUpdateCmd_DoNotDeleteOldChartsOnError(t *testing.T) { } } - // Make sure tmpcharts is deleted - if _, err := os.Stat(filepath.Join(dir(chartname), "tmpcharts")); !os.IsNotExist(err) { + // Make sure tmpcharts-x is deleted + tmpPath := filepath.Join(dir(chartname), fmt.Sprintf("tmpcharts-%d", os.Getpid())) + if _, err := os.Stat(tmpPath); !os.IsNotExist(err) { t.Fatalf("tmpcharts dir still exists") } }