From 6b800509d0a4166c83192789ea4b679fba76387a Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Tue, 7 May 2019 18:05:18 +0200 Subject: [PATCH] Add comment to explain why the repositories file is read a second time Signed-off-by: Patrick Decat --- cmd/helm/repo_add.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/helm/repo_add.go b/cmd/helm/repo_add.go index 0257367d6..ebb27e684 100644 --- a/cmd/helm/repo_add.go +++ b/cmd/helm/repo_add.go @@ -135,7 +135,7 @@ func addRepository(name, url, username, password string, home helmpath.Home, cer return fmt.Errorf("Looks like %q is not a valid chart repository or cannot be reached: %s", url, err.Error()) } - // Lock the repository file for concurrent processes synchronization and re-read its content before updating it + // Lock the repository file for concurrent goroutines or processes synchronization fileLock := flock.New(home.RepositoryFile()) lockCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() @@ -147,6 +147,8 @@ func addRepository(name, url, username, password string, home helmpath.Home, cer return err } + // Re-read the repositories file before updating it as its content may have been changed + // by a concurrent execution after the first read and before being locked f, err = repo.LoadRepositoriesFile(home.RepositoryFile()) if err != nil { return err