Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roachprod: guard calls to SetupSSH #96794

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pkg/roachprod/roachprod.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,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 @@ -577,6 +578,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