dashboard, buildlet, cmd/debugnewvm: clean up HostConfig.ContainerVMImage

The debugnewvm command was printing out the wrong VM name, since the
old method had also assumed (but not documented) that it only applied
to nested virtualization containers. But remove that requirement and
make the empty string mean unspecified instead (which we currently
mean to use Container-Optimized OS) role and then use its new
definition.

Change-Id: Ieca138285aa567b1c24d585c5aa180f8a1534154
Reviewed-on: https://go-review.googlesource.com/c/build/+/177919
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
Brad Fitzpatrick 2019-05-17 20:08:13 +00:00
Родитель b392e07185
Коммит 6994fc2d58
3 изменённых файлов: 17 добавлений и 5 удалений

Просмотреть файл

@ -146,7 +146,9 @@ func StartNewVM(creds *google.Credentials, buildEnv *buildenv.Environment, instN
if hconf.IsContainer() {
if hconf.NestedVirt {
minCPU = "Intel Haswell" // documented minimum from https://cloud.google.com/compute/docs/instances/enable-nested-virtualization-vm-instances
srcImage = "https://www.googleapis.com/compute/v1/projects/" + projectID + "/global/images/" + hconf.ContainerVMImage()
}
if vm := hconf.ContainerVMImage(); vm != "" {
srcImage = "https://www.googleapis.com/compute/v1/projects/" + projectID + "/global/images/" + vm
} else {
var err error
srcImage, err = cosImage(ctx, computeService)

Просмотреть файл

@ -81,7 +81,11 @@ func main() {
}
vmImageSummary := fmt.Sprintf("%q", hconf.VMImage)
if hconf.IsContainer() {
vmImageSummary = fmt.Sprintf("%q, running container %q", hconf.ContainerVMImage(), hconf.ContainerImage)
containerHost := hconf.ContainerVMImage()
if containerHost == "" {
containerHost = "default container host"
}
vmImageSummary = fmt.Sprintf("%s, running container %q", containerHost, hconf.ContainerImage)
}
env = buildenv.FromFlags()

Просмотреть файл

@ -1140,13 +1140,19 @@ func (c *HostConfig) PoolName() string {
// ContainerVMImage returns the base VM name (not the fully qualified
// URL resource name of the VM) that starts the konlet program that
// pulls & runs a container. This method is only applicable when
// c.IsContainer() is true.
// pulls & runs a container.
// The empty string means that no particular VM image is required
// and the caller can run this container in any host.
//
// This method is only applicable when c.IsContainer() is true.
func (c *HostConfig) ContainerVMImage() string {
if c.KonletVMImage != "" {
return c.KonletVMImage
}
return "debian-stretch-vmx"
if c.NestedVirt {
return "debian-stretch-vmx"
}
return ""
}
// IsHermetic reports whether this host config gets a fresh