From 8a433c10676b07f3f9e04e1b2d53064c02c63a14 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Mon, 1 Apr 2019 22:01:42 +1300 Subject: [PATCH 01/15] suggested change from spellcheck --- script/fmtpolice | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/fmtpolice b/script/fmtpolice index bed08dbe4..b0fedee3a 100755 --- a/script/fmtpolice +++ b/script/fmtpolice @@ -2,7 +2,7 @@ set -o errexit main() { - if [[ ! -n "${1}" ]]; then + if [[ -z "${1}" ]]; then git ls-files '*.go' | while read -r f; do __gofmt_check "${f}" done From 014f849cf6e907eb29b1f4fddbbab88743c6918d Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Mon, 1 Apr 2019 22:06:17 +1300 Subject: [PATCH 02/15] raise early if there isn't an ACCOUNT_JSON env var --- backend/gce.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/gce.go b/backend/gce.go index ccd3de5f1..a0ceadef9 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -312,6 +312,10 @@ func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) { return nil, err } + if !cfg.IsSet("ACCOUNT_JSON") { + return nil, fmt.Errorf("missing ACCOUNT_JSON") + } + projectID := cfg.Get("PROJECT_ID") if metadata.OnGCE() { projectID, err = metadata.ProjectID() From 5151ff11761729c1175dc93226e9931801f777d6 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Mon, 1 Apr 2019 22:09:21 +1300 Subject: [PATCH 03/15] random zone selection within a region --- backend/gce.go | 144 +++++++++++++++++++++---------------------------- 1 file changed, 62 insertions(+), 82 deletions(-) diff --git a/backend/gce.go b/backend/gce.go index a0ceadef9..5a18af9e0 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -48,7 +48,6 @@ import ( ) const ( - defaultGCEZone = "us-central1-a" defaultGCEMachineType = "n1-standard-2" defaultGCEPremiumMachineType = "n1-standard-4" defaultGCENetwork = "default" @@ -59,7 +58,6 @@ const ( defaultGCEStopPollSleep = 3 * time.Second defaultGCEStopPrePollSleep = 15 * time.Second defaultGCESubnet = "default" - defaultGCERegion = "us-central1" defaultGCEUploadRetries = uint64(120) defaultGCEUploadRetrySleep = 1 * time.Second defaultGCEImageSelectorType = "env" @@ -95,7 +93,7 @@ var ( "NETWORK": fmt.Sprintf("network name (default %q)", defaultGCENetwork), "PREEMPTIBLE": "boot job instances with preemptible flag enabled (default false)", "PREMIUM_MACHINE_TYPE": fmt.Sprintf("premium machine type (default %q)", defaultGCEPremiumMachineType), - "PROJECT_ID": "[REQUIRED] GCE project id", + "PROJECT_ID": "[REQUIRED] GCE project id (will try to auto detect it if not set)", "PUBLIC_IP": "boot job instances with a public ip, disable this for NAT (default true)", "PUBLIC_IP_CONNECT": "connect to the public ip of the instance instead of the internal, only takes effect if PUBLIC_IP is true (default true)", "IMAGE_PROJECT_ID": "GCE project id to use for images, will use PROJECT_ID if not specified", @@ -107,8 +105,8 @@ var ( "RATE_LIMIT_DYNAMIC_CONFIG": "get max-calls and duration dynamically through redis (default false)", "RATE_LIMIT_DYNAMIC_CONFIG_TTL": fmt.Sprintf("time to cache dynamic config for (default %v)", defaultGCERateLimitDynamicConfigTTL), - "BACKOFF_RETRY_MAX": "Maximum allowed duration of generic exponential backoff retries (default 1m)", - "REGION": fmt.Sprintf("only takes effect when SUBNETWORK is defined; region in which to deploy (default %v)", defaultGCERegion), + "BACKOFF_RETRY_MAX": "maximum allowed duration of generic exponential backoff retries (default 1m)", + "REGION": "[REQUIRED] region in which to deploy", "SKIP_STOP_POLL": "immediately return after issuing first instance deletion request (default false)", "SSH_DIAL_TIMEOUT": fmt.Sprintf("connection timeout for ssh connections (default %v)", defaultGCESSHDialTimeout), "STOP_POLL_SLEEP": fmt.Sprintf("sleep interval between polling server for instance stop status (default %v)", defaultGCEStopPollSleep), @@ -119,7 +117,7 @@ var ( "WARMER_URL": "URL for warmer service", "WARMER_TIMEOUT": fmt.Sprintf("timeout for requests to warmer service (default %v)", defaultGCEWarmerTimeout), "WARMER_SSH_PASSPHRASE": fmt.Sprintf("The passphrase used to decipher instace SSH keys"), - "ZONE": fmt.Sprintf("zone name (default %q)", defaultGCEZone), + "ZONE": "zone in which to deploy job instaces into (default is to use all zones in the region)", } errGCEMissingIPAddressError = fmt.Errorf("no IP address found") @@ -182,7 +180,7 @@ type gceProvider struct { imageProjectID string ic *gceInstanceConfig cfg *config.ProviderConfig - alternateZones []string + allZonesForRegion []string machineTypeSelfLinks map[string]string backoffRetryMax time.Duration @@ -257,7 +255,6 @@ type gceStartContext struct { instanceWarmedIP string windowsPassword string zoneName string - zonePinned bool machineType string premiumMachineType string } @@ -332,18 +329,24 @@ func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) { imageProjectID = cfg.Get("IMAGE_PROJECT_ID") } - zoneName := defaultGCEZone - if metadata.OnGCE() { - zoneName, err = metadata.Zone() + region := "" + if cfg.IsSet("REGION") { + region = cfg.Get("REGION") + } else if metadata.OnGCE() { + zoneName, err := metadata.Zone() if err != nil { return nil, errors.Wrap(err, "could not get zone from metadata api") } - } - if cfg.IsSet("ZONE") { - zoneName = cfg.Get("ZONE") + zone, zErr := client.Zones.Get(projectID, zoneName).Do() + if zErr != nil { + return nil, errors.Wrap(zErr, "could not get zone from compute api") + } + region = zone.Region + } else { + return nil, fmt.Errorf("missing REGION") } - cfg.Set("ZONE", zoneName) + cfg.Set("REGION", region) mtName := defaultGCEMachineType if cfg.IsSet("MACHINE_TYPE") { @@ -603,7 +606,7 @@ func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) { projectID: projectID, imageProjectID: imageProjectID, cfg: cfg, - alternateZones: []string{}, + allZonesForRegion: []string{}, machineTypeSelfLinks: map[string]string{}, sshDialer: sshDialer, sshDialTimeout: sshDialTimeout, @@ -703,27 +706,26 @@ func (p *gceProvider) apiRateLimit(ctx gocontext.Context) error { func (p *gceProvider) Setup(ctx gocontext.Context) error { logger := context.LoggerFromContext(ctx).WithField("self", "backend/gce_provider") - logger.WithField("zone", p.cfg.Get("ZONE")).Debug("resolving configured zone") + if p.cfg.Get("ZONE") != "" { + logger.WithField("zone", p.cfg.Get("ZONE")).Debug("resolving configured zone") - err := p.backoffRetry(ctx, func() error { - p.apiRateLimit(ctx) - zone, zErr := p.client.Zones. - Get(p.projectID, p.cfg.Get("ZONE")). - Context(ctx). - Do() - if zErr == nil { - p.ic.Zone = zone - } - return zErr - }) + err := p.backoffRetry(ctx, func() error { + p.apiRateLimit(ctx) + zone, zErr := p.client.Zones.Get(p.projectID, p.cfg.Get("ZONE")).Context(ctx).Do() + if zErr == nil { + p.ic.Zone = zone + } + return zErr + }) - if err != nil { - return errors.Wrap(err, "failed to resolve configured zone") + if err != nil { + return errors.Wrap(err, "failed to resolve configured zone") + } } logger.WithField("network", p.cfg.Get("NETWORK")).Debug("resolving configured network") - err = p.backoffRetry(ctx, func() error { + err := p.backoffRetry(ctx, func() error { p.apiRateLimit(ctx) nw, nwErr := p.client.Networks. Get(p.projectID, p.cfg.Get("NETWORK")). @@ -736,17 +738,18 @@ func (p *gceProvider) Setup(ctx gocontext.Context) error { }) if err != nil { - return errors.Wrap(err, "failed te resolve configured network") + return errors.Wrap(err, "failed to resolve configured network") } - region := defaultGCERegion - if metadata.OnGCE() { - logger.WithField("region", p.ic.Zone.Region).Debug("setting region from zone when on gce") - region = p.ic.Zone.Region - } + region := "" if p.cfg.IsSet("REGION") { - logger.WithField("region", p.ic.Zone.Region).Debug("setting region from config") + logger.WithField("region", p.cfg.Get("REGION")).Debug("setting region from config") region = p.cfg.Get("REGION") + } else if metadata.OnGCE() { + logger.WithField("region", p.ic.Zone.Region).Debug("setting region from zone when on gce") + region = p.ic.Zone.Region + } else { + return errors.Wrap(err, "failed to resolve configured region") } if p.cfg.IsSet("SUBNETWORK") { @@ -769,33 +772,36 @@ func (p *gceProvider) Setup(ctx gocontext.Context) error { } } - logger.Debug("finding alternate zones") + logger.Debug("finding all zones for region") err = p.backoffRetry(ctx, func() error { p.apiRateLimit(ctx) + + regionURL := fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/regions/%s", p.projectID, p.cfg.Get("REGION")) + zl, zlErr := p.client.Zones.List(p.projectID). Context(ctx). Filter("status eq UP"). - Filter(fmt.Sprintf("region eq %s", p.ic.Zone.Region)).Do() + Filter(fmt.Sprintf("region eq %s", regionURL)).Do() if zlErr != nil { return zlErr } - p.alternateZones = []string{} + p.allZonesForRegion = []string{} for _, z := range zl.Items { - p.alternateZones = append(p.alternateZones, z.Name) + p.allZonesForRegion = append(p.allZonesForRegion, z.Name) } return nil }) if err != nil { - return errors.Wrap(err, "failed to find alternate zones") + return errors.Wrap(err, "failed to find zones for region") } logger.Debug("building machine type self link map") - for _, zoneName := range append([]string{p.ic.Zone.Name}, p.alternateZones...) { + for _, zoneName := range p.allZonesForRegion { for _, machineType := range []string{p.ic.MachineType, p.ic.PremiumMachineType} { if zoneName == "" || machineType == "" { continue @@ -919,7 +925,6 @@ func (p *gceProvider) StartWithProgress(ctx gocontext.Context, startAttributes * c := &gceStartContext{ startAttributes: startAttributes, - zoneName: p.ic.Zone.Name, machineType: p.ic.MachineType, premiumMachineType: p.ic.PremiumMachineType, progresser: progresser, @@ -1055,22 +1060,7 @@ func (p *gceProvider) stepInsertInstance(c *gceStartContext) multistep.StepActio logger := context.LoggerFromContext(c.ctx).WithField("self", "backend/gce_provider") - if c.startAttributes.VMConfig.Zone != "" { - err := p.backoffRetry(ctx, func() error { - p.apiRateLimit(ctx) - zone, zErr := p.client.Zones.Get(p.projectID, c.startAttributes.VMConfig.Zone).Context(ctx).Do() - if zErr != nil { - return zErr - } - c.zoneName = zone.Name - c.zonePinned = true - return nil - }) - - if err != nil { - return multistep.ActionHalt - } - } + c.zoneName = p.pickZone("") inst, err := p.buildInstance(ctx, c) if err != nil { @@ -1152,15 +1142,13 @@ func (p *gceProvider) stepInsertInstance(c *gceStartContext) multistep.StepActio op, insErr := p.client.Instances.Insert(p.projectID, c.zoneName, c.instance).Context(c.ctx).Do() if insErr != nil { - if !c.zonePinned { - altZone := p.pickAlternateZone(c.zoneName) - logger.WithFields(logrus.Fields{ - "err": insErr, - "prev_zone": c.zoneName, - "next_zone": altZone, - }).Warn("switching zones due to error") - p.setStartContextZone(c, altZone) - } + nextZone := p.pickZone(c.zoneName) + logger.WithFields(logrus.Fields{ + "err": insErr, + "prev_zone": c.zoneName, + "next_zone": nextZone, + }).Warn("switching zones due to error") + p.setStartContextZone(c, nextZone) return insErr } @@ -1624,20 +1612,12 @@ func (p *gceProvider) warmerRequestInstance(ctx gocontext.Context, zone string, return warmerRes, nil } -func (p *gceProvider) pickAlternateZone(zoneName string) string { - if len(p.alternateZones) == 0 { - return zoneName +func (p *gceProvider) pickZone(zoneName string) string { + if p.cfg.Get("ZONE") != "" { + return p.cfg.Get("ZONE") } - for { - altZone := p.alternateZones[mathrand.Intn(len(p.alternateZones))] - if altZone != zoneName { - return altZone - } - if len(p.alternateZones) == 1 { - return zoneName - } - } + return p.allZonesForRegion[mathrand.Intn(len(p.allZonesForRegion))] } func (p *gceProvider) setStartContextZone(c *gceStartContext, zoneName string) { From df0475025a58c75519222c6a99bf297d5272f083 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Mon, 1 Apr 2019 23:02:20 +1300 Subject: [PATCH 04/15] fix a spec by defining the region --- backend/gce_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/gce_test.go b/backend/gce_test.go index 2cb667796..bf85b23f9 100644 --- a/backend/gce_test.go +++ b/backend/gce_test.go @@ -74,6 +74,7 @@ func gceTestSetup(t *testing.T, cfg *config.ProviderConfig, resp *gceTestRespons "PROJECT_ID": "project_id", "IMAGE_ALIASES": "foo", "IMAGE_ALIAS_FOO": "default", + "REGION": "us-central1", }) } From e745dad52fa734ea7e3394b02d957ee31ca16988 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 4 Apr 2019 23:08:36 +1300 Subject: [PATCH 05/15] add support for specifying a minimum cpu platform --- backend/gce.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/gce.go b/backend/gce.go index 5a18af9e0..7afe44553 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -90,6 +90,7 @@ var ( "IMAGE_SELECTOR_URL": "URL for image selector API, used only when image selector is \"api\"", "IMAGE_[ALIAS_]{ALIAS}": "full name for a given alias given via IMAGE_ALIASES, where the alias form in the key is uppercased and normalized by replacing non-alphanumerics with _", "MACHINE_TYPE": fmt.Sprintf("machine name (default %q)", defaultGCEMachineType), + "MINIMUM_CPU_PLATFORM": "minimum cpu platform", "NETWORK": fmt.Sprintf("network name (default %q)", defaultGCENetwork), "PREEMPTIBLE": "boot job instances with preemptible flag enabled (default false)", "PREMIUM_MACHINE_TYPE": fmt.Sprintf("premium machine type (default %q)", defaultGCEPremiumMachineType), @@ -210,6 +211,7 @@ type gceProvider struct { } type gceInstanceConfig struct { + MinimumCpuPlatform string MachineType string PremiumMachineType string Zone *compute.Zone @@ -348,6 +350,11 @@ func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) { cfg.Set("REGION", region) + minimumCpuPlatform := "" + if cfg.IsSet("MINIMUM_CPU_PLATFORM") { + minimumCpuPlatform = cfg.Get("MINIMUM_CPU_PLATFORM") + } + mtName := defaultGCEMachineType if cfg.IsSet("MACHINE_TYPE") { mtName = cfg.Get("MACHINE_TYPE") @@ -623,6 +630,7 @@ func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) { SkipStopPoll: skipStopPoll, Site: site, AcceleratorConfig: defaultAcceleratorConfig, + MinimumCpuPlatform: minimumCpuPlatform, MachineType: mtName, PremiumMachineType: premiumMTName, }, @@ -1449,6 +1457,10 @@ func (p *gceProvider) buildInstance(ctx gocontext.Context, c *gceStartContext) ( }, } + if p.ic.MinimumCpuPlatform != "" { + inst.MinCpuPlatform = p.ic.MinimumCpuPlatform + } + machineType := p.ic.MachineType if c.startAttributes.VMType == "premium" { machineType = p.ic.PremiumMachineType From c48a622ec025b247857c2ce1e67cbab1789d8823 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 5 Apr 2019 14:43:56 +1300 Subject: [PATCH 06/15] throw an error if we can't fetch the zones --- backend/gce.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/gce.go b/backend/gce.go index 7afe44553..b51658db5 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -800,6 +800,10 @@ func (p *gceProvider) Setup(ctx gocontext.Context) error { p.allZonesForRegion = append(p.allZonesForRegion, z.Name) } + if len(p.allZonesForRegion) == 0 { + return fmt.Errorf("no zones found for region %s", p.cfg.Get("REGION")) + } + return nil }) From fc073c59058992ea5550e82d79f660fb1462fe7a Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 5 Apr 2019 15:07:15 +1300 Subject: [PATCH 07/15] a little more logging --- backend/gce.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/gce.go b/backend/gce.go index b51658db5..ae095fa0a 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -721,6 +721,7 @@ func (p *gceProvider) Setup(ctx gocontext.Context) error { p.apiRateLimit(ctx) zone, zErr := p.client.Zones.Get(p.projectID, p.cfg.Get("ZONE")).Context(ctx).Do() if zErr == nil { + logger.WithField("zone", zone).Info("resolved configured zone") p.ic.Zone = zone } return zErr @@ -751,10 +752,10 @@ func (p *gceProvider) Setup(ctx gocontext.Context) error { region := "" if p.cfg.IsSet("REGION") { - logger.WithField("region", p.cfg.Get("REGION")).Debug("setting region from config") + logger.WithField("region", p.cfg.Get("REGION")).Info("setting region from config") region = p.cfg.Get("REGION") } else if metadata.OnGCE() { - logger.WithField("region", p.ic.Zone.Region).Debug("setting region from zone when on gce") + logger.WithField("region", p.ic.Zone.Region).Info("setting region from zone when on gce") region = p.ic.Zone.Region } else { return errors.Wrap(err, "failed to resolve configured region") From 2d15bc81d739d1955d2f079d736648eea394109b Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 5 Apr 2019 15:36:15 +1300 Subject: [PATCH 08/15] some smarter region extraction --- backend/gce.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/gce.go b/backend/gce.go index ae095fa0a..626d0a743 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -14,6 +14,7 @@ import ( mathrand "math/rand" "net/http" "net/url" + "regexp" "sort" "strconv" "strings" @@ -343,7 +344,9 @@ func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) { if zErr != nil { return nil, errors.Wrap(zErr, "could not get zone from compute api") } - region = zone.Region + fullZoneURI := fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/regions/(.*)", projectID) + re := regexp.MustCompile(regexp.QuoteMeta(fullZoneURI)) + region = re.FindStringSubmatch(zone.Region)[1] } else { return nil, fmt.Errorf("missing REGION") } From d64695a56de3e50b01742a6f9f939a3d9bd46dd8 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 5 Apr 2019 17:05:27 +1300 Subject: [PATCH 09/15] fix the index for the regex match --- backend/gce.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/gce.go b/backend/gce.go index 626d0a743..edb4be2dd 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -346,7 +346,7 @@ func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) { } fullZoneURI := fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/regions/(.*)", projectID) re := regexp.MustCompile(regexp.QuoteMeta(fullZoneURI)) - region = re.FindStringSubmatch(zone.Region)[1] + region = re.FindStringSubmatch(zone.Region)[0] } else { return nil, fmt.Errorf("missing REGION") } From a029f46e095b02967de5d20bc5c8de30419af698 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 5 Apr 2019 17:58:18 +1300 Subject: [PATCH 10/15] changes to the regex --- backend/gce.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/gce.go b/backend/gce.go index edb4be2dd..1a6d982cb 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -344,8 +344,9 @@ func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) { if zErr != nil { return nil, errors.Wrap(zErr, "could not get zone from compute api") } - fullZoneURI := fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/regions/(.*)", projectID) - re := regexp.MustCompile(regexp.QuoteMeta(fullZoneURI)) + zoneURI := fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/regions/(.*)", projectID) + quotedZoneURI := strings.ReplaceAll(zoneURI, "/", "\\/") + re := regexp.MustCompile(quotedZoneURI) region = re.FindStringSubmatch(zone.Region)[0] } else { return nil, fmt.Errorf("missing REGION") From fbd03092fdf63d85fb477e7c1c5a61e9d1925b50 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 5 Apr 2019 18:14:42 +1300 Subject: [PATCH 11/15] ReplaceAll is a 1.12 method --- backend/gce.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/gce.go b/backend/gce.go index 1a6d982cb..53e2073cd 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -345,7 +345,7 @@ func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) { return nil, errors.Wrap(zErr, "could not get zone from compute api") } zoneURI := fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/regions/(.*)", projectID) - quotedZoneURI := strings.ReplaceAll(zoneURI, "/", "\\/") + quotedZoneURI := strings.Replace(zoneURI, "/", "\\/", -1) re := regexp.MustCompile(quotedZoneURI) region = re.FindStringSubmatch(zone.Region)[0] } else { From 6be50c69bca4f1e2aa1c38c96365c34d591526bb Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 5 Apr 2019 18:29:40 +1300 Subject: [PATCH 12/15] urg, use [1] not [0] --- backend/gce.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/gce.go b/backend/gce.go index 53e2073cd..1ac630bf7 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -347,7 +347,7 @@ func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) { zoneURI := fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/regions/(.*)", projectID) quotedZoneURI := strings.Replace(zoneURI, "/", "\\/", -1) re := regexp.MustCompile(quotedZoneURI) - region = re.FindStringSubmatch(zone.Region)[0] + region = re.FindStringSubmatch(zone.Region)[1] } else { return nil, fmt.Errorf("missing REGION") } From 8d1df6c0ce6ddb612fb343f4becc3b85b6b84b30 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Tue, 25 Jun 2019 19:16:09 +1200 Subject: [PATCH 13/15] remove whitespace Co-Authored-By: fixmie[bot] <44270338+fixmie[bot]@users.noreply.github.com> --- backend/gce.go | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/gce.go b/backend/gce.go index b0609eaab..de241d9d9 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -740,7 +740,6 @@ func (p *gceProvider) Setup(ctx gocontext.Context) error { err = p.backoffRetry(ctx, func() error { _ = p.apiRateLimit(ctx) - nw, nwErr := p.client.Networks. Get(p.projectID, p.cfg.Get("NETWORK")). Context(ctx). From 0810378c5831e76a4333147365f1e79d34eb8347 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Tue, 25 Jun 2019 19:24:16 +1200 Subject: [PATCH 14/15] missing a : can mean a lot --- backend/gce.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/gce.go b/backend/gce.go index de241d9d9..0c032824a 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -738,7 +738,7 @@ func (p *gceProvider) Setup(ctx gocontext.Context) error { logger.WithField("network", p.cfg.Get("NETWORK")).Debug("resolving configured network") - err = p.backoffRetry(ctx, func() error { + err := p.backoffRetry(ctx, func() error { _ = p.apiRateLimit(ctx) nw, nwErr := p.client.Networks. Get(p.projectID, p.cfg.Get("NETWORK")). From 2472f028f6a06056e8dfbe1ab002fcbea6df4191 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Tue, 25 Jun 2019 19:26:07 +1200 Subject: [PATCH 15/15] fix a spelling mistake --- backend/gce.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/gce.go b/backend/gce.go index 0c032824a..f9539a70d 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -119,7 +119,7 @@ var ( "WARMER_URL": "URL for warmer service", "WARMER_TIMEOUT": fmt.Sprintf("timeout for requests to warmer service (default %v)", defaultGCEWarmerTimeout), "WARMER_SSH_PASSPHRASE": fmt.Sprintf("The passphrase used to decipher instace SSH keys"), - "ZONE": "zone in which to deploy job instaces into (default is to use all zones in the region)", + "ZONE": "zone in which to deploy job instances into (default is to use all zones in the region)", } errGCEMissingIPAddressError = fmt.Errorf("no IP address found")