From 8ab1308e06b817c567df018bbee4c162dd3774d8 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 18 Dec 2019 09:08:37 +0100 Subject: pkg/gce: fix creation of non-preemptible E2 instances --- pkg/gce/gce.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'pkg/gce') diff --git a/pkg/gce/gce.go b/pkg/gce/gce.go index 0ba0c50c0..59731a858 100644 --- a/pkg/gce/gce.go +++ b/pkg/gce/gce.go @@ -138,6 +138,11 @@ func (ctx *Context) CreateInstance(name, machineType, image, sshkey string, pree } retry: + if !instance.Scheduling.Preemptible && strings.HasPrefix(machineType, "e2-") { + // Otherwise we get "Error 400: Efficient instances do not support + // onHostMaintenance=TERMINATE unless they are preemptible". + instance.Scheduling.OnHostMaintenance = "MIGRATE" + } var op *compute.Operation err := ctx.apiCall(func() (err error) { op, err = ctx.computeService.Instances.Insert(ctx.ProjectID, ctx.ZoneID, instance).Do() -- cgit mrf-deployment