Skip to content

Commit

Permalink
Merge pull request #128223 from cockroachdb/blathers/backport-release…
Browse files Browse the repository at this point in the history
…-24.1-128207

release-24.1: dev: in `doctor`, add `--sandbox_add_mount_pair` if relevant
  • Loading branch information
rickystewart authored Aug 2, 2024
2 parents b6cd3d1 + 5c67ddf commit 8dd815d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dev
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi
set -euo pipefail

# Bump this counter to force rebuilding `dev` on all machines.
DEV_VERSION=97
DEV_VERSION=98

THIS_DIR=$(cd "$(dirname "$0")" && pwd)
BINARY_DIR=$THIS_DIR/bin/dev-versions
Expand Down
53 changes: 53 additions & 0 deletions pkg/cmd/dev/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,59 @@ slightly slower and introduce a noticeable delay in first-time build setup.`
},
remoteOnly: true,
},
{
name: "sandbox_add_mount_pair_local",
check: func(d *dev, _ context.Context, cfg doctorConfig) string {
// This check only matters for Linux machines.
if runtime.GOOS != "linux" {
return ""
}
if !d.checkLinePresenceInBazelRcUser(cfg.workspace, "test --test_tmpdir=/tmp") {
return ""
}
if d.checkLinePresenceInBazelRcUser(cfg.workspace, "test --sandbox_add_mount_pair=/tmp") {
return ""
}
return "Should set --sandbox_add_mount_pair=/tmp given the use of --test_tmpdir=/tmp"
},
autofix: func(d *dev, ctx context.Context, cfg doctorConfig) error {
if !cfg.haveAutofixPermission && cfg.interactive {
response := promptInteractiveInput("Do you want me to update your .bazelrc.user file for you? I will add a line `test --sandbox_add_mount_pair=/tmp`.", "y")
canAutofix, ok := toBoolFuzzy(response)
if ok && canAutofix {
cfg.haveAutofixPermission = true
}
}
if !cfg.haveAutofixPermission {
return fmt.Errorf("do not have permission to update .bazelrc.user")
}
return d.addLineToBazelRcUser(cfg.workspace, "test --sandbox_add_mount_pair=/tmp")
},
nonRemoteOnly: true,
},
{
name: "sandbox_add_mount_pair_remote",
check: func(d *dev, _ context.Context, cfg doctorConfig) string {
if d.checkLinePresenceInBazelRcUser(cfg.workspace, "test --sandbox_add_mount_pair=/tmp") {
return "Should not set --sandbox_add_mount_pair in remote mode"
}
return ""
},
autofix: func(d *dev, ctx context.Context, cfg doctorConfig) error {
if !cfg.haveAutofixPermission && cfg.interactive {
response := promptInteractiveInput("Do you want me to update your .bazelrc.user file for you? I will remove all --sandbox_add_mount_pair from your .bazelrc.user", "y")
canAutofix, ok := toBoolFuzzy(response)
if ok && canAutofix {
cfg.haveAutofixPermission = true
}
}
if !cfg.haveAutofixPermission {
return fmt.Errorf("do not have permission to update .bazelrc.user")
}
return d.removeAllPrefixesInFile(filepath.Join(cfg.workspace, ".bazelrc.user"), "test --sandbox_add_mount_pair")
},
remoteOnly: true,
},
{
name: "patchelf",
check: func(d *dev, ctx context.Context, cfg doctorConfig) string {
Expand Down

0 comments on commit 8dd815d

Please sign in to comment.