Skip to content

Commit

Permalink
buildenv: remove EC2 zone configuration options
Browse files Browse the repository at this point in the history
There is no need to set availability zones for EC2 resources at this
time. The resources currently in use are available to all zones within
a single region.

For golang/go#36841

Change-Id: Ifcb2c3404fba2489741c31fe63ad4e7747639ad9
Reviewed-on: https://go-review.googlesource.com/c/build/+/255359
Trust: Carlos Amedee <carlos@golang.org>
Run-TryBot: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
  • Loading branch information
cagedmantis committed Sep 16, 2020
1 parent ac829c2 commit 43d625a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 63 deletions.
21 changes: 0 additions & 21 deletions buildenv/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,11 @@ type Environment struct {
// other fields.
ControlZone string

// PreferredEC2Zone is the preffered AWS availability zone.
PreferredEC2Zone string

// VMZones are the GCE zones that the VMs will be deployed to. These
// GCE zones will be periodically cleaned by deleting old VMs. The zones
// should all exist within a single region.
VMZones []string

// VMEC2Zones are the AWS availability zones that the VMs will be deployed to.
// The availability zones should all exist within a single region.
VMEC2Zones []string

// StaticIP is the public, static IP address that will be attached to the
// coordinator instance. The zero value means the address will be looked
// up by name. This field is optional.
Expand Down Expand Up @@ -149,8 +142,6 @@ type Environment struct {
AWSSecurityGroup string

// AWSRegion is the region where AWS resources are deployed.
// The availability zones set in VMEC2Zones should all reside
// within this region.
AWSRegion string
}

Expand All @@ -168,16 +159,6 @@ func (e Environment) RandomVMZone() string {
return e.VMZones[rand.Intn(len(e.VMZones))]
}

// RandomEC2VMZone returns a randomly selected zone from the zones in
// VMAvailabilityZones. The PreferredAvailabilityZone value will be
// returned if VMAvailabilityZones is not set.
func (e Environment) RandomEC2VMZone() string {
if len(e.VMEC2Zones) == 0 {
return e.PreferredEC2Zone
}
return e.VMEC2Zones[rand.Intn(len(e.VMEC2Zones))]
}

// Region returns the GCE region, derived from its zone.
func (e Environment) Region() string {
return e.ControlZone[:strings.LastIndex(e.ControlZone, "-")]
Expand Down Expand Up @@ -266,7 +247,6 @@ var Staging = &Environment{
IsProd: true,
ControlZone: "us-central1-f",
VMZones: []string{"us-central1-a", "us-central1-b", "us-central1-c", "us-central1-f"},
VMEC2Zones: []string{"us-east-1a", "us-east-1b"},
StaticIP: "104.154.113.235",
MachineType: "n1-standard-1",
PreferContainersOnCOS: true,
Expand Down Expand Up @@ -302,7 +282,6 @@ var Production = &Environment{
IsProd: true,
ControlZone: "us-central1-f",
VMZones: []string{"us-central1-a", "us-central1-b", "us-central1-c", "us-central1-f"},
VMEC2Zones: []string{"us-east-2a", "us-east-2b"},
StaticIP: "107.178.219.46",
MachineType: "n1-standard-4",
PreferContainersOnCOS: true,
Expand Down
42 changes: 0 additions & 42 deletions buildenv/envs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,48 +50,6 @@ func TestEnvironmentNextZone(t *testing.T) {
}
}

func TestEnvironmentRandomEC2VMZone(t *testing.T) {
testCases := []struct {
name string
env Environment
wantOneOf []string
}{
{
name: "zones-not-set",
env: Environment{
PreferredEC2Zone: "zone-a",
VMEC2Zones: []string{},
},
wantOneOf: []string{"zone-a"},
},
{
name: "zone-and-zones-set",
env: Environment{
PreferredEC2Zone: "zone-a",
VMEC2Zones: []string{"zone-b", "zone-c"},
},

wantOneOf: []string{"zone-b", "zone-c"},
},
{
name: "zones-only-contains-one-entry",
env: Environment{
PreferredEC2Zone: "zone-a",
VMEC2Zones: []string{"zone-b"},
},
wantOneOf: []string{"zone-b"},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
got := tc.env.RandomEC2VMZone()
if !containsString(got, tc.wantOneOf) {
t.Errorf("got=%q; want %v", got, tc.wantOneOf)
}
})
}
}

func containsString(item string, items []string) bool {
for _, s := range items {
if item == s {
Expand Down

0 comments on commit 43d625a

Please sign in to comment.