Skip to content

Commit

Permalink
cmd/buildlet: always halt Mac VMs after builds, regardless of macOS v…
Browse files Browse the repository at this point in the history
…ersion

We used to do this only by necessity on Sierra, due to Sierra issues,
but now that x/build/cmd/makemac is better, we can just do this all
the time. Doing it always is better anyway, to guarantee fresh
environments per build.

Also add the forgotten sudo in the Mac halt. The
env/darwin/macstadium/image-setup-notes.txt even calls out how to
setup password-free sudo to the images, but then I forgot to use it.
It only worked before (if it did?) because the process ended and
failed its heartbeat, at least some of the time. It's also possible it
was never working. The old reason that Sierra machines were
special-cased to reboot was reportedly fixed anyway, in
golang/go#18751 (comment).

Updates golang/go#9495

Change-Id: Iea21d7bc07467429cde79f4212c2b91458f8d8d8
Reviewed-on: https://go-review.googlesource.com/82355
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
bradfitz committed Dec 7, 2017
1 parent 7b0a998 commit 73f4eec
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions cmd/buildlet/buildlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ var (
// 8: mac screensaver disabled
// 11: move from self-signed cert to LetsEncrypt (Issue 16442)
// 15: ssh support
const buildletVersion = 15
// 16: make macstadium builders always haltEntireOS
// 17: make macstadium halts use sudo
const buildletVersion = 17

func defaultListenAddr() string {
if runtime.GOOS == "darwin" {
Expand Down Expand Up @@ -1160,7 +1162,7 @@ func doHalt() {
case "darwin":
if os.Getenv("GO_BUILDER_ENV") == "macstadium_vm" {
// Fast, sloppy, unsafe, because we're never reusing this VM again.
err = exec.Command("/sbin/halt", "-n", "-q", "-l").Run()
err = exec.Command("/usr/bin/sudo", "/sbin/halt", "-n", "-q", "-l").Run()
} else {
err = errors.New("not respecting -halt flag on macOS in unknown environment")
}
Expand Down Expand Up @@ -1565,7 +1567,7 @@ func killProcessTreeUnix(p *os.Process) error {
// configureMacStadium configures the buildlet flags for use on a Mac
// VM running on MacStadium under VMWare.
func configureMacStadium() {
*haltEntireOS = false // for now
*haltEntireOS = true

// TODO: setup RAM disk for tmp and set *workDir

Expand All @@ -1581,12 +1583,6 @@ func configureMacStadium() {
log.Fatalf("unsupported sw_vers version %q", version)
}
major, minor := m[1], m[2] // "10", "12"
if minor == "12" {
// macOS Sierra wedges its network stack if it runs
// all.bash a few times in a row. Reboot between each
// build.
*haltEntireOS = true
}
*reverse = "darwin-amd64-" + major + "_" + minor
*coordinator = "farmer.golang.org:443"

Expand Down

0 comments on commit 73f4eec

Please sign in to comment.