@@ -47,6 +47,7 @@ import (
47
47
"go4.org/syncutil"
48
48
grpc "grpc.go4.org"
49
49
50
+ "cloud.google.com/go/compute/metadata"
50
51
"cloud.google.com/go/errorreporting"
51
52
"cloud.google.com/go/storage"
52
53
"golang.org/x/build"
@@ -985,9 +986,8 @@ func findTryWork() error {
985
986
log .Printf ("Warning: skipping incomplete %#v" , work )
986
987
continue
987
988
}
988
- if work .Project == "build" || work .Project == "grpc-review" {
989
- // Skip trybot request in build repo.
990
- // Also skip grpc-review, which is only for reviews for now.
989
+ if work .Project == "grpc-review" {
990
+ // Skip grpc-review, which is only for reviews for now.
991
991
continue
992
992
}
993
993
key := tryWorkItemKey (work )
@@ -1073,6 +1073,8 @@ func tryWorkItemKey(work *apipb.GerritTryWorkItem) tryKey {
1073
1073
}
1074
1074
}
1075
1075
1076
+ var testingKnobSkipBuilds bool
1077
+
1076
1078
// newTrySet creates a new trySet group of builders for a given
1077
1079
// work item, the (Project, Branch, Change-ID, Commit) tuple.
1078
1080
// It also starts goroutines for each build.
@@ -1108,11 +1110,16 @@ func newTrySet(work *apipb.GerritTryWorkItem) *trySet {
1108
1110
idx := len (ts .builds )
1109
1111
ts .builds = append (ts .builds , bs )
1110
1112
ts .remain ++
1113
+ if testingKnobSkipBuilds {
1114
+ return
1115
+ }
1111
1116
go bs .start () // acquires statusMu itself, so in a goroutine
1112
1117
go ts .awaitTryBuild (idx , bs , brev )
1113
1118
}
1114
1119
1115
- go ts .notifyStarting ()
1120
+ if ! testingKnobSkipBuilds {
1121
+ go ts .notifyStarting ()
1122
+ }
1116
1123
for _ , bconf := range builders {
1117
1124
brev := tryKeyToBuilderRev (bconf .Name , key , goRev )
1118
1125
bs , err := newBuild (brev )
@@ -1130,6 +1137,10 @@ func newTrySet(work *apipb.GerritTryWorkItem) *trySet {
1130
1137
work .GoCommit = work .GoCommit [:len (work .GoBranch )]
1131
1138
}
1132
1139
1140
+ // linuxBuilder is the standard builder we run for when testing x/* repos against
1141
+ // the past two Go releases.
1142
+ linuxBuilder := dashboard .Builders ["linux-amd64" ]
1143
+
1133
1144
// If there's more than one GoCommit, that means this is an x/* repo
1134
1145
// and we're testing against previous releases of Go.
1135
1146
for i , goRev := range work .GoCommit {
@@ -1138,7 +1149,10 @@ func newTrySet(work *apipb.GerritTryWorkItem) *trySet {
1138
1149
continue
1139
1150
}
1140
1151
branch := work .GoBranch [i ]
1141
- brev := tryKeyToBuilderRev ("linux-amd64" , key , goRev )
1152
+ if ! linuxBuilder .BuildBranch (key .Project , "master" , branch ) {
1153
+ continue
1154
+ }
1155
+ brev := tryKeyToBuilderRev (linuxBuilder .Name , key , goRev )
1142
1156
bs , err := newBuild (brev )
1143
1157
if err != nil {
1144
1158
log .Printf ("can't create build for %q: %v" , brev , err )
@@ -1344,6 +1358,9 @@ func (ts *trySet) noteBuildComplete(bs *buildStatus) {
1344
1358
}
1345
1359
}
1346
1360
1361
+ // skipBuild reports whether the br build should be skipped.
1362
+ //
1363
+ // TODO(bradfitz): move this policy func into dashboard/builders.go in its own CL sometime.
1347
1364
func skipBuild (br buildgo.BuilderRev ) bool {
1348
1365
if br .Name == "freebsd-arm-paulzhol" {
1349
1366
// This was a fragile little machine with limited memory.
@@ -1356,11 +1373,20 @@ func skipBuild(br buildgo.BuilderRev) bool {
1356
1373
return true
1357
1374
}
1358
1375
switch br .SubName {
1359
- case "build" , // has external deps
1360
- "exp" , // always broken, depends on mobile which is broken
1376
+ case "oauth2" , "build" :
1377
+ // The oauth2 and build repos are our guinea pigs for
1378
+ // testing using modules. But they currently only work
1379
+ // inside the GCP network.
1380
+ // TODO: once we proxy through the module proxy from
1381
+ // reverse buildlets' localhost:3000 to
1382
+ // authenticated+TLS farmer.golang.org to the GKE
1383
+ // service, then we can use modules less
1384
+ // conditionally.
1385
+ bc , ok := dashboard .Builders [br .Name ]
1386
+ return ! ok || bc .IsReverse ()
1387
+ case "exp" , // always broken, depends on mobile which is broken
1361
1388
"mobile" , // always broken (gl, etc). doesn't compile.
1362
- "term" , // no code yet in repo: "warning: "golang.org/x/term/..." matched no packages"
1363
- "oauth2" : // has external deps
1389
+ "term" : // no code yet in repo,
1364
1390
return true
1365
1391
case "perf" :
1366
1392
if br .Name == "linux-amd64-nocgo" {
@@ -2690,10 +2716,11 @@ func (st *buildStatus) runSubrepoTests() (remoteErr, err error) {
2690
2716
return nil , nil
2691
2717
}
2692
2718
2693
- // Recursively fetch the repo and its dependencies.
2694
- // Dependencies are always fetched at master, which isn't
2695
- // great but the dashboard data model doesn't track
2696
- // sub-repo dependencies. TODO(adg): fix this somehow??
2719
+ // Recursively fetch the repo and their golang.org/x/*
2720
+ // dependencies. Dependencies are always fetched at master,
2721
+ // which isn't great but the dashboard data model doesn't
2722
+ // track non-golang.org/x/* dependencies. For those, we
2723
+ // require on the code under test to be using Go modules.
2697
2724
for i := 0 ; i < len (toFetch ); i ++ {
2698
2725
repo := toFetch [i ]
2699
2726
if fetched [repo ] {
@@ -2725,17 +2752,70 @@ func (st *buildStatus) runSubrepoTests() (remoteErr, err error) {
2725
2752
2726
2753
sp := st .CreateSpan ("running_subrepo_tests" , st .SubName )
2727
2754
defer func () { sp .Done (err ) }()
2755
+
2756
+ goProxy , err := st .moduleProxy ()
2757
+ if err != nil {
2758
+ return nil , err
2759
+ }
2760
+ var go111Module , dir string
2761
+ if goProxy != "" {
2762
+ go111Module = "on"
2763
+ dir = "gopath/src/golang.org/x/" + st .SubName
2764
+ }
2765
+
2728
2766
return st .bc .Exec (path .Join ("go" , "bin" , "go" ), buildlet.ExecOpts {
2729
2767
Output : st ,
2768
+ Dir : dir ,
2730
2769
ExtraEnv : append (st .conf .Env (),
2731
2770
"GOROOT=" + goroot ,
2732
2771
"GOPATH=" + gopath ,
2772
+ "GO111MODULE=" + go111Module ,
2773
+ "GOPROXY=" + goProxy ,
2733
2774
),
2734
2775
Path : []string {"$WORKDIR/go/bin" , "$PATH" },
2735
2776
Args : []string {"test" , "-short" , subrepoPrefix + st .SubName + "/..." },
2736
2777
})
2737
2778
}
2738
2779
2780
+ // moduleProxy returns the GOPROXY environment value to use for this
2781
+ // build's tests. If non-empty, GO111MODULE=on is included in the
2782
+ // environment as well. Returning two zero values means to not
2783
+ // configure the environment values.
2784
+ //
2785
+ // We go through a GCP-project-internal module proxy ("GOPROXY") to
2786
+ // eliminate load on the origin servers. Our builder VMs are ephemeral
2787
+ // and only run for the duration of one build. They also often don't
2788
+ // have all the VCS tools installed (or even available: there is no
2789
+ // git for plan9).
2790
+ func (bs * buildStatus ) moduleProxy () (string , error ) {
2791
+ switch bs .SubName {
2792
+ case "oauth2" , "build" :
2793
+ // The two repos we're starting with for testing.
2794
+ default :
2795
+ return "" , nil
2796
+ }
2797
+ // If we're running on localhost, just use the current environment's value.
2798
+ if buildEnv == nil || ! buildEnv .IsProd {
2799
+ return os .Getenv ("GOPROXY" ), nil
2800
+ }
2801
+
2802
+ // We run a NodePort service on each GKE node
2803
+ // (cmd/coordinator/module-proxy-service.yaml) on port 30156
2804
+ // that maps to the Athens service. We could round robin over
2805
+ // all the GKE nodes' IPs if we wanted, but the coordinator is
2806
+ // running on GKE so our node by definition is up, so just use it.
2807
+ // It won't be much traffic.
2808
+ // TODO: migrate to a GKE internal load balancer with an internal static IP
2809
+ // once we migrate symbolic-datum-552 off a Legacy VPC network to the modern
2810
+ // scheme that supports internal static IPs.
2811
+ gkeNodeIP , err := metadata .Get ("instance/network-interfaces/0/ip" )
2812
+ if err != nil || gkeNodeIP == "" {
2813
+ log .Printf ("WARNING: failed to discover local GCE node's IP: %v; disabling GOPROXY" , err )
2814
+ return "" , nil
2815
+ }
2816
+ return "http://" + gkeNodeIP + ":30156" , nil
2817
+ }
2818
+
2739
2819
// affectedPkgs returns the name of every package affected by this commit.
2740
2820
// The returned list may contain duplicates and is unsorted.
2741
2821
// It is safe to call this on a nil trySet.
0 commit comments