Skip to content

Commit 2b2acc8

Browse files
committed
buildlet: raise ulimit for NetBSD
The NetBSD 8 builders had a very low RLIMIT_DATA (even as root). The builders don't run run.bash, which normally increases the ulimit. So do it ourselves on start-up. Currently this is only on NetBSD. Deployed and verified it works now. Fixes golang/go#22871 Change-Id: I6ecb38b985ce27f0f29b36b55367eb1729be29c9 Reviewed-on: https://go-review.googlesource.com/79955 Reviewed-by: Benny Siegert <[email protected]> Reviewed-by: Andrew Bonventre <[email protected]>
1 parent 0d9bf6f commit 2b2acc8

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

cmd/buildlet/buildlet.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func defaultListenAddr() string {
9595
var (
9696
osHalt func()
9797
configureSerialLogOutput func()
98+
setOSRlimit func() error
9899
)
99100

100101
func main() {
@@ -134,6 +135,13 @@ func main() {
134135
case "openbsd", "freebsd", "netbsd":
135136
makeBSDFilesystemFast()
136137
}
138+
if setOSRlimit != nil {
139+
err := setOSRlimit()
140+
if err != nil {
141+
log.Fatalf("setOSRLimit: %v", err)
142+
}
143+
log.Printf("set OS rlimits.")
144+
}
137145

138146
if *reverse != "" && *reverseType != "" {
139147
log.Fatalf("can't specify both --reverse and --reverse-type")

cmd/buildlet/buildlet_netbsd.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2017 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
"os"
9+
10+
"golang.org/x/sys/unix"
11+
)
12+
13+
func init() {
14+
setOSRlimit = setNetBSDRlimit
15+
}
16+
17+
// See https://github.com/golang/go/issues/22871#issuecomment-346888363
18+
func setNetBSDRlimit() error {
19+
limit := unix.Rlimit{
20+
Cur: unix.RLIM_INFINITY,
21+
Max: unix.RLIM_INFINITY,
22+
}
23+
if err := unix.Setrlimit(unix.RLIMIT_DATA, &limit); err != nil && os.Getuid() == 0 {
24+
return err
25+
}
26+
return nil
27+
}

0 commit comments

Comments
 (0)