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 <bsiegert@gmail.com>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
This commit is contained in:
Brad Fitzpatrick 2017-11-26 22:34:54 +00:00
Родитель 0d9bf6f794
Коммит 2b2acc8cf1
2 изменённых файлов: 35 добавлений и 0 удалений

Просмотреть файл

@ -95,6 +95,7 @@ func defaultListenAddr() string {
var (
osHalt func()
configureSerialLogOutput func()
setOSRlimit func() error
)
func main() {
@ -134,6 +135,13 @@ func main() {
case "openbsd", "freebsd", "netbsd":
makeBSDFilesystemFast()
}
if setOSRlimit != nil {
err := setOSRlimit()
if err != nil {
log.Fatalf("setOSRLimit: %v", err)
}
log.Printf("set OS rlimits.")
}
if *reverse != "" && *reverseType != "" {
log.Fatalf("can't specify both --reverse and --reverse-type")

Просмотреть файл

@ -0,0 +1,27 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"os"
"golang.org/x/sys/unix"
)
func init() {
setOSRlimit = setNetBSDRlimit
}
// See https://github.com/golang/go/issues/22871#issuecomment-346888363
func setNetBSDRlimit() error {
limit := unix.Rlimit{
Cur: unix.RLIM_INFINITY,
Max: unix.RLIM_INFINITY,
}
if err := unix.Setrlimit(unix.RLIMIT_DATA, &limit); err != nil && os.Getuid() == 0 {
return err
}
return nil
}