Skip to content

Commit c328d04

Browse files
committed
all: misc cleanup, docs, actually add Alpine builder
-- move policy of which builders are trybots out of coordinator and into dashboard/builders.go. -- move some GCE-specific code from coordinator.go to gce.go. -- rename an old "watcher" reference to "gitmirror" -- add some docs -- actually add the Alpine builder, missing from https://golang.org/cl/33890 Fixes golang/go#17891 Change-Id: Ia63671ca09aec322ed57b3663e0ac5042cdc56f2 Reviewed-on: https://go-review.googlesource.com/40395 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 20b85ed commit c328d04

File tree

4 files changed

+101
-58
lines changed

4 files changed

+101
-58
lines changed

cmd/coordinator/coordinator.go

+7-47
Original file line numberDiff line numberDiff line change
@@ -104,31 +104,10 @@ var (
104104
)
105105

106106
func initTryBuilders() {
107-
names := []string{
108-
"darwin-amd64-10_11",
109-
"linux-386",
110-
"linux-amd64",
111-
"linux-amd64-race",
112-
"linux-amd64-ssacheck",
113-
"freebsd-amd64-gce101",
114-
"windows-386-gce",
115-
"windows-amd64-gce",
116-
"openbsd-amd64-60",
117-
"nacl-386",
118-
"nacl-amd64p32",
119-
"linux-arm",
120-
"misc-vet-vetall",
121-
}
122-
for name := range dashboard.Builders {
123-
if strings.HasPrefix(name, "misc-compile") {
124-
names = append(names, name)
125-
}
126-
}
127-
for _, name := range names {
107+
for _, name := range dashboard.TrybotBuilderNames() {
128108
conf, ok := dashboard.Builders[name]
129109
if !ok {
130-
log.Printf("ignoring invalid try builder config %q", name)
131-
continue
110+
panic("bogus")
132111
}
133112
tryBuilders = append(tryBuilders, conf)
134113
if conf.BuildSubrepos() {
@@ -149,27 +128,6 @@ const (
149128
podDeleteTimeout = 45 * time.Minute
150129
)
151130

152-
func readGCSFile(name string) ([]byte, error) {
153-
if *mode == "dev" {
154-
b, ok := testFiles[name]
155-
if !ok {
156-
return nil, &os.PathError{
157-
Op: "open",
158-
Path: name,
159-
Err: os.ErrNotExist,
160-
}
161-
}
162-
return []byte(b), nil
163-
}
164-
165-
r, err := storageClient.Bucket(buildEnv.BuildletBucket).Object(name).NewReader(context.Background())
166-
if err != nil {
167-
return nil, err
168-
}
169-
defer r.Close()
170-
return ioutil.ReadAll(r)
171-
}
172-
173131
// Fake keys signed by a fake CA.
174132
// These are used in localhost dev mode. (Not to be confused with the
175133
// staging "dev" instance under GCE project "go-dashboard-dev")
@@ -320,7 +278,7 @@ func main() {
320278
workc := make(chan builderRev)
321279

322280
if *mode == "dev" {
323-
// TODO(crawshaw): do more in test mode
281+
// TODO(crawshaw): do more in dev mode
324282
gcePool.SetEnabled(*devEnableGCE)
325283
http.HandleFunc("/dosomework/", handleDoSomeWork(workc))
326284
} else {
@@ -3145,6 +3103,8 @@ func (st *buildStatus) Write(p []byte) (n int, err error) {
31453103
return st.output.Write(p)
31463104
}
31473105

3106+
// versionTgz returns an io.Reader of a *.tar.gz file containing only
3107+
// a VERSION file containing the contents of the provided rev string.
31483108
func versionTgz(rev string) io.Reader {
31493109
var buf bytes.Buffer
31503110
zw := gzip.NewWriter(&buf)
@@ -3175,7 +3135,7 @@ var sourceGroup singleflight.Group
31753135

31763136
var sourceCache = lru.New(40) // git rev -> []byte
31773137

3178-
func useWatcher() bool {
3138+
func useGitMirror() bool {
31793139
return *mode != "dev"
31803140
}
31813141

@@ -3191,7 +3151,7 @@ func getSourceTgz(sl spanLogger, repo, rev string, isTry bool) (tgz io.Reader, e
31913151
return tgzBytes, nil
31923152
}
31933153

3194-
if useWatcher() {
3154+
if useGitMirror() {
31953155
sp := sl.createSpan("get_source_from_gitmirror")
31963156
tgzBytes, err := getSourceTgzFromGitMirror(repo, rev)
31973157
if err == nil {

cmd/coordinator/gce.go

+22
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"io"
1616
"io/ioutil"
1717
"log"
18+
"os"
1819
"path"
1920
"sort"
2021
"strconv"
@@ -629,3 +630,24 @@ func (c *gcsAutocertCache) Delete(ctx context.Context, key string) error {
629630
}
630631
return err
631632
}
633+
634+
func readGCSFile(name string) ([]byte, error) {
635+
if *mode == "dev" {
636+
b, ok := testFiles[name]
637+
if !ok {
638+
return nil, &os.PathError{
639+
Op: "open",
640+
Path: name,
641+
Err: os.ErrNotExist,
642+
}
643+
}
644+
return []byte(b), nil
645+
}
646+
647+
r, err := storageClient.Bucket(buildEnv.BuildletBucket).Object(name).NewReader(context.Background())
648+
if err != nil {
649+
return nil, err
650+
}
651+
defer r.Close()
652+
return ioutil.ReadAll(r)
653+
}

dashboard/builders.go

+49-11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package dashboard
88

99
import (
1010
"fmt"
11+
"sort"
1112
"strconv"
1213
"strings"
1314

@@ -17,6 +18,7 @@ import (
1718
// Builders are the different build configurations.
1819
// The keys are like "darwin-amd64" or "linux-386-387".
1920
// This map should not be modified by other packages.
21+
// Initialization happens below, via calls to addBuilder.
2022
var Builders = map[string]BuildConfig{}
2123

2224
// Hosts contains the names and configs of all the types of
@@ -119,13 +121,6 @@ var Hosts = map[string]*HostConfig{
119121
goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/go1.4-freebsd-amd64.tar.gz",
120122
env: []string{"CC=clang"},
121123
},
122-
"host-netbsd-70": &HostConfig{
123-
VMImage: "netbsd-amd64-70",
124-
Notes: "NetBSD 7.0_2016Q4; GCE VM is built from script in build/env/netbsd-amd64",
125-
machineType: "n1-highcpu-2",
126-
buildletURLTmpl: "http://storage.googleapis.com/$BUCKET/buildlet.netbsd-amd64",
127-
goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/gobootstrap-netbsd-amd64.tar.gz",
128-
},
129124
"host-netbsd-71": &HostConfig{
130125
VMImage: "netbsd-amd64-71",
131126
Notes: "NetBSD 7.1RC1; GCE VM is built from script in build/env/netbsd-amd64",
@@ -409,6 +404,7 @@ type BuildConfig struct {
409404

410405
Notes string // notes for humans
411406

407+
TryBot bool // be a trybot
412408
TryOnly bool // only used for trybots, and not regular builds
413409
CompileOnly bool // if true, compile tests, but don't run them
414410
FlakyNet bool // network tests are flaky (try anyway, but ignore some failures)
@@ -683,6 +679,7 @@ func init() {
683679
addBuilder(BuildConfig{
684680
Name: "freebsd-amd64-gce101",
685681
HostType: "host-freebsd-101-gce",
682+
TryBot: true,
686683
numTestHelpers: 2,
687684
numTryTestHelpers: 4,
688685
})
@@ -707,6 +704,7 @@ func init() {
707704
addBuilder(BuildConfig{
708705
Name: "linux-386",
709706
HostType: "host-linux-kubestd",
707+
TryBot: true,
710708
env: []string{"GOARCH=386", "GOHOSTARCH=386"},
711709
numTestHelpers: 1,
712710
numTryTestHelpers: 3,
@@ -720,21 +718,28 @@ func init() {
720718
addBuilder(BuildConfig{
721719
Name: "linux-amd64",
722720
HostType: "host-linux-kubestd",
721+
TryBot: true,
723722
numTestHelpers: 3,
724723
})
724+
addBuilder(BuildConfig{
725+
Name: "linux-amd64-alpine",
726+
HostType: "host-linux-x86-alpine",
727+
})
725728
// Add the -vetall builder. The builder name suffix "-vetall" is recognized by cmd/dist/test.go
726729
// to only run the "go vet std cmd" test and no others.
727730
addBuilder(BuildConfig{
728731
Name: "misc-vet-vetall",
729732
HostType: "host-linux-kubestd",
730733
Notes: "Runs vet over the standard library.",
734+
TryBot: true,
731735
numTestHelpers: 5,
732736
})
733737

734738
addMiscCompile := func(suffix, rx string) {
735739
addBuilder(BuildConfig{
736740
Name: "misc-compile" + suffix,
737741
HostType: "host-linux-kubestd",
742+
TryBot: true,
738743
TryOnly: true,
739744
CompileOnly: true,
740745
Notes: "Runs buildall.sh to cross-compile std packages for " + rx + ", but doesn't run any tests.",
@@ -772,13 +777,15 @@ func init() {
772777
addBuilder(BuildConfig{
773778
Name: "linux-amd64-ssacheck",
774779
HostType: "host-linux-kubestd",
780+
TryBot: true,
775781
CompileOnly: true,
776782
Notes: "SSA internal checks enabled",
777783
env: []string{"GO_GCFLAGS=-d=ssa/check/on,dclstack"},
778784
})
779785
addBuilder(BuildConfig{
780786
Name: "linux-amd64-race",
781787
HostType: "host-linux-kubestd",
788+
TryBot: true,
782789
numTestHelpers: 2,
783790
numTryTestHelpers: 5,
784791
})
@@ -808,6 +815,7 @@ func init() {
808815
addBuilder(BuildConfig{
809816
Name: "linux-arm",
810817
HostType: "host-linux-arm",
818+
TryBot: true,
811819
FlakyNet: true,
812820
numTestHelpers: 2,
813821
numTryTestHelpers: 7,
@@ -836,26 +844,27 @@ func init() {
836844
addBuilder(BuildConfig{
837845
Name: "nacl-386",
838846
HostType: "host-nacl-kube",
847+
TryBot: true,
839848
numTestHelpers: 3,
840849
env: []string{"GOOS=nacl", "GOARCH=386", "GOHOSTOS=linux", "GOHOSTARCH=amd64"},
841850
})
842851
addBuilder(BuildConfig{
843852
Name: "nacl-amd64p32",
844853
HostType: "host-nacl-kube",
854+
TryBot: true,
845855
numTestHelpers: 3,
846856
env: []string{"GOOS=nacl", "GOARCH=amd64p32", "GOHOSTOS=linux", "GOHOSTARCH=amd64"},
847857
})
848858
addBuilder(BuildConfig{
849859
Name: "openbsd-amd64-60",
850860
HostType: "host-openbsd-amd64-60",
861+
TryBot: true,
851862
numTestHelpers: 2,
852863
numTryTestHelpers: 5,
853864
})
854865
addBuilder(BuildConfig{
855-
Name: "openbsd-386-60",
856-
HostType: "host-openbsd-386-60",
857-
numTestHelpers: 2,
858-
numTryTestHelpers: 5,
866+
Name: "openbsd-386-60",
867+
HostType: "host-openbsd-386-60",
859868
})
860869
addBuilder(BuildConfig{
861870
Name: "netbsd-amd64-71",
@@ -875,6 +884,7 @@ func init() {
875884
Name: "windows-amd64-gce",
876885
HostType: "host-windows-gce",
877886
env: []string{"GOARCH=amd64", "GOHOSTARCH=amd64"},
887+
TryBot: true,
878888
numTestHelpers: 1,
879889
numTryTestHelpers: 5,
880890
})
@@ -888,6 +898,7 @@ func init() {
888898
Name: "windows-386-gce",
889899
HostType: "host-windows-gce",
890900
env: []string{"GOARCH=386", "GOHOSTARCH=386"},
901+
TryBot: true,
891902
numTestHelpers: 1,
892903
numTryTestHelpers: 5,
893904
})
@@ -902,6 +913,7 @@ func init() {
902913
addBuilder(BuildConfig{
903914
Name: "darwin-amd64-10_11",
904915
HostType: "host-darwin-10_11",
916+
TryBot: true,
905917
numTestHelpers: 2,
906918
numTryTestHelpers: 3,
907919
})
@@ -1037,6 +1049,8 @@ func (c BuildConfig) isMobile() bool {
10371049
return strings.HasPrefix(c.Name, "android-") || strings.HasPrefix(c.Name, "darwin-arm")
10381050
}
10391051

1052+
// addBuilder adds c to the Builders map after doing some sanity
1053+
// checks.
10401054
func addBuilder(c BuildConfig) {
10411055
if c.Name == "" {
10421056
panic("empty name")
@@ -1062,5 +1076,29 @@ func addBuilder(c BuildConfig) {
10621076
if _, ok := Hosts[c.HostType]; !ok {
10631077
panic(fmt.Sprintf("undefined HostType %q for builder %q", c.HostType, c.Name))
10641078
}
1079+
1080+
types := 0
1081+
for _, fn := range []func() bool{c.IsReverse, c.IsKube, c.IsGCE} {
1082+
if fn() {
1083+
types++
1084+
}
1085+
}
1086+
if types != 1 {
1087+
panic(fmt.Sprintf("build config %q host type inconsistent (must be Reverse, Kube, or GCE)", c.Name))
1088+
}
1089+
10651090
Builders[c.Name] = c
10661091
}
1092+
1093+
// TrybotBuilderNames returns the names of the builder configs
1094+
// with the TryBot field set true.
1095+
func TrybotBuilderNames() []string {
1096+
var ret []string
1097+
for name, conf := range Builders {
1098+
if conf.TryBot {
1099+
ret = append(ret, name)
1100+
}
1101+
}
1102+
sort.Strings(ret)
1103+
return ret
1104+
}

dashboard/builders_test.go

+23
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,26 @@ func TestOSARCHAccessors(t *testing.T) {
2020
}
2121
}
2222
}
23+
24+
func TestListTrybots(t *testing.T) {
25+
tryBots := TrybotBuilderNames()
26+
t.Logf("Builders:")
27+
for _, name := range tryBots {
28+
t.Logf(" - %s", name)
29+
}
30+
}
31+
32+
func TestHostConfigsAllUsed(t *testing.T) {
33+
used := map[string]bool{}
34+
for _, conf := range Builders {
35+
used[conf.HostType] = true
36+
}
37+
for hostType := range Hosts {
38+
if !used[hostType] {
39+
// Currently host-linux-armhf-cross and host-linux-armel-cross aren't
40+
// referenced, but the coordinator hard-codes them, so don't make
41+
// this an error for now.
42+
t.Logf("warning: host type %q is not referenced from any build config", hostType)
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)