Skip to content

Commit

Permalink
fix(helm): fix 'error preparing chart dependencies... file exists'
Browse files Browse the repository at this point in the history
Error may occur when concurrent processes fulfill cache directory.

Fixed by additional check of directory existance after lock has been acquired.

Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed May 31, 2022
1 parent 5992f96 commit 3f32bf0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/deploy/helm/chart_extender/chart_dependencies_loader.go
Expand Up @@ -74,6 +74,15 @@ func GetPreparedChartDependenciesDir(ctx context.Context, metadataFile, metadata
}
defer werf.ReleaseHostLock(lock)

switch _, err := os.Stat(depsDir); {
case os.IsNotExist(err):
case err != nil:
return fmt.Errorf("error accessing %s: %w", depsDir, err)
default:
// at the time we have acquired a lock the target directory was created
return nil
}

tmpDepsDir := fmt.Sprintf("%s.tmp.%s", depsDir, uuid.NewV4().String())

buildChartDependenciesOpts.LoadOptions = &loader.LoadOptions{
Expand Down

0 comments on commit 3f32bf0

Please sign in to comment.