internal/coordinator/pool: drop delete timeout context option
CL 207841 removed the last use of this option. Additionally, the
scheduler makes setting this option from somewhere difficult as the
scheduler constructs a new background context to pass to the pool. As a
result, this option is unlikely to be used going forward.
Change-Id: I1aed89e72f35fc01b3ec9bf9f164f92b32143ffe
Reviewed-on: https://go-review.googlesource.com/c/build/+/378335
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Alex Rakoczy <alex@golang.org>
diff --git a/internal/coordinator/pool/ec2.go b/internal/coordinator/pool/ec2.go
index 712764c..866b480 100644
--- a/internal/coordinator/pool/ec2.go
+++ b/internal/coordinator/pool/ec2.go
@@ -195,7 +195,7 @@
Zone: "", // allow the EC2 api pick an availability zone with capacity
TLS: kp,
Meta: make(map[string]string),
- DeleteIn: determineDeleteTimeout(ctx, hconf, eb.vmDeleteTimeout),
+ DeleteIn: determineDeleteTimeout(hconf, eb.vmDeleteTimeout),
OnInstanceRequested: func() {
log.Printf("EC2 VM %q now booting", instName)
},
diff --git a/internal/coordinator/pool/gce.go b/internal/coordinator/pool/gce.go
index 5dad67f..629d165 100644
--- a/internal/coordinator/pool/gce.go
+++ b/internal/coordinator/pool/gce.go
@@ -417,7 +417,7 @@
log.Printf("Creating GCE VM %q for %s at %s", instName, hostType, zone)
bc, err = buildlet.StartNewVM(gcpCreds, buildEnv, instName, hostType, buildlet.VMOpts{
- DeleteIn: determineDeleteTimeout(ctx, hconf, deleteTimeout),
+ DeleteIn: determineDeleteTimeout(hconf, deleteTimeout),
OnInstanceRequested: func() {
log.Printf("GCE VM %q now booting", instName)
},
diff --git a/internal/coordinator/pool/kube.go b/internal/coordinator/pool/kube.go
index c6db75c..3e762b2 100644
--- a/internal/coordinator/pool/kube.go
+++ b/internal/coordinator/pool/kube.go
@@ -270,7 +270,7 @@
ProjectID: NewGCEConfiguration().BuildEnv().ProjectName,
ImageRegistry: registryPrefix,
Description: fmt.Sprintf("Go Builder for %s", hostType),
- DeleteIn: determineDeleteTimeout(ctx, hconf, podDeleteTimeout),
+ DeleteIn: determineDeleteTimeout(hconf, podDeleteTimeout),
OnPodCreating: func() {
lg.LogEventTime("pod_creating")
p.setPodUsed(podName, true)
diff --git a/internal/coordinator/pool/pool.go b/internal/coordinator/pool/pool.go
index c42a173..6fa00ca 100644
--- a/internal/coordinator/pool/pool.go
+++ b/internal/coordinator/pool/pool.go
@@ -19,9 +19,6 @@
"golang.org/x/build/dashboard"
)
-// BuildletTimeoutOpt is a context.Value key for BuildletPool.GetBuildlet.
-type BuildletTimeoutOpt struct{} // context Value key; value is time.Duration
-
// Buildlet defines an interface for a pool of buildlets.
type Buildlet interface {
// GetBuildlet returns a new buildlet client.
@@ -32,9 +29,6 @@
//
// Users of GetBuildlet must both call Client.Close when done
// with the client as well as cancel the provided Context.
- //
- // The ctx may have context values of type buildletTimeoutOpt
- // and highPriorityOpt.
GetBuildlet(ctx context.Context, hostType string, lg Logger) (buildlet.Client, error)
String() string // TODO(bradfitz): more status stuff
@@ -77,18 +71,11 @@
// determineDeleteTimeout determines the buildlet timeout duration with the
// following priority:
//
-// 1. Value from context
-// 2. Host type default from host config.
-// 3. Global default from 'timeout'.
-func determineDeleteTimeout(ctx context.Context, host *dashboard.HostConfig, timeout time.Duration) time.Duration {
- deleteIn, ok := ctx.Value(BuildletTimeoutOpt{}).(time.Duration)
- if ok {
- return deleteIn
- }
-
- deleteIn = host.DeleteTimeout
- if deleteIn != 0 {
- return deleteIn
+// 1. Host type default from host config.
+// 2. Global default from 'timeout'.
+func determineDeleteTimeout(host *dashboard.HostConfig, timeout time.Duration) time.Duration {
+ if host.DeleteTimeout != 0 {
+ return host.DeleteTimeout
}
return timeout
diff --git a/internal/coordinator/pool/pool_test.go b/internal/coordinator/pool/pool_test.go
index e1955c4..266d1cd 100644
--- a/internal/coordinator/pool/pool_test.go
+++ b/internal/coordinator/pool/pool_test.go
@@ -8,7 +8,6 @@
package pool
import (
- "context"
"testing"
"time"
@@ -18,28 +17,18 @@
func TestPoolDetermineDeleteTimeout(t *testing.T) {
testCases := []struct {
desc string
- ctxValue interface{}
hostValue time.Duration
timeout time.Duration
wantTimeout time.Duration
}{
{
- desc: "from-context",
- ctxValue: time.Hour,
- hostValue: time.Minute,
- timeout: time.Second,
- wantTimeout: time.Hour,
- },
- {
desc: "from-host",
- ctxValue: nil,
hostValue: time.Minute,
timeout: time.Second,
wantTimeout: time.Minute,
},
{
desc: "from-argument",
- ctxValue: nil,
hostValue: 0,
timeout: time.Second,
wantTimeout: time.Second,
@@ -47,15 +36,11 @@
}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
- ctx := context.Background()
- if tc.ctxValue != nil {
- ctx = context.WithValue(ctx, BuildletTimeoutOpt{}, tc.ctxValue)
- }
h := &dashboard.HostConfig{
DeleteTimeout: tc.hostValue,
}
- if got := determineDeleteTimeout(ctx, h, tc.timeout); got != tc.wantTimeout {
- t.Errorf("determineDeleteTimeout(%+v, %+v, %s) = %s; want %s", ctx, h, tc.timeout, got, tc.wantTimeout)
+ if got := determineDeleteTimeout(h, tc.timeout); got != tc.wantTimeout {
+ t.Errorf("determineDeleteTimeout(%+v, %s) = %s; want %s", h, tc.timeout, got, tc.wantTimeout)
}
})
}