Skip to content

Commit

Permalink
Merge pull request #97560 from herkolategan/backport22.1-96794
Browse files Browse the repository at this point in the history
  • Loading branch information
herkolategan authored Mar 6, 2023
2 parents e70037f + e72a8f2 commit 41deb77
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/roachprod/roachprod.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ func CachedClusters(l *logger.Logger, fn func(clusterName string, numVMs int)) {
}
}

// acquireFilesystemLock acquires a filesystem lock so that two concurrent
// synchronizations of roachprod state don't clobber each other.
// acquireFilesystemLock acquires a filesystem lock in order that concurrent
// operations or roachprod processes that access shared system resources do
// not conflict.
func acquireFilesystemLock() (unlockFn func(), _ error) {
lockFile := os.ExpandEnv("$HOME/.roachprod/LOCK")
f, err := os.Create(lockFile)
Expand Down Expand Up @@ -555,6 +556,11 @@ func SetupSSH(ctx context.Context, l *logger.Logger, clusterName string) error {

// Configure SSH for machines in the zones we operate on.
if err := vm.ProvidersSequential(providers, func(p vm.Provider) error {
unlock, lockErr := acquireFilesystemLock()
if lockErr != nil {
return lockErr
}
defer unlock()
return p.ConfigSSH(zones[p.Name()])
}); err != nil {
return err
Expand Down

0 comments on commit 41deb77

Please sign in to comment.