From ed753e7349f54732fb40624a983801cf2b2e1485 Mon Sep 17 00:00:00 2001 From: Pavel Dotsulenko Date: Fri, 31 Jan 2020 16:02:00 +0200 Subject: [PATCH 1/2] Allow to set custom disk size for windows --- backend/gce.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/backend/gce.go b/backend/gce.go index fa17560b8..19ffd696f 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -84,6 +84,7 @@ var ( "DEFAULT_LANGUAGE": fmt.Sprintf("default language to use when looking up image (default %q)", defaultGCELanguage), "DETERMINISTIC_HOSTNAME": "assign deterministic hostname based on repo slug and job id (default false)", "DISK_SIZE": fmt.Sprintf("disk size in GB (default %v)", defaultGCEDiskSize), + "DISK_SIZE_WINDOWS": "disk size in GB for windows OS (defaults to DISK_SIZE value)", "GPU_COUNT": fmt.Sprintf("number of GPUs to use (default %v)", defaultGCEGpuCount), "GPU_TYPE": fmt.Sprintf("type of GPU to use (default %q)", defaultGCEGpuType), "IMAGE_ALIASES": "comma-delimited strings used as stable names for images, used only when image selector type is \"env\"", @@ -218,6 +219,7 @@ type gceInstanceConfig struct { Subnetwork *compute.Subnetwork AcceleratorConfig *compute.AcceleratorConfig DiskSize int64 + DiskSizeWindows int64 SSHPubKey string AutoImplode bool HardTimeoutMinutes int64 @@ -372,6 +374,14 @@ func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) { } } + diskSizeWindows := defaultGCEDiskSize + if cfg.IsSet("DISK_SIZE_WINDOWS") { + ds, err := strconv.ParseInt(cfg.Get("DISK_SIZE_WINDOWS"), 10, 64) + if err == nil { + diskSizeWindows = ds + } + } + bootPollSleep := defaultGCEBootPollSleep if cfg.IsSet("BOOT_POLL_SLEEP") { si, err := time.ParseDuration(cfg.Get("BOOT_POLL_SLEEP")) @@ -615,6 +625,7 @@ func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) { PublicIP: publicIP, PublicIPConnect: publicIPConnect, DiskSize: diskSize, + DiskSizeWindows: diskSizeWindows, SSHPubKey: string(pubKey), AutoImplode: autoImplode, StopPollSleep: stopPollSleep, @@ -1463,10 +1474,15 @@ func (p *gceProvider) buildInstance(ctx gocontext.Context, c *gceStartContext) ( Zone: c.zoneName, } + diskSize := p.ic.DiskSize + if c.startAttributes.OS == "windows" { + diskSize = p.ic.DiskSizeWindows + } + diskInitParams := &compute.AttachedDiskInitializeParams{ SourceImage: c.image.SelfLink, DiskType: gcePdSSDForZone(c.zoneName), - DiskSizeGb: p.ic.DiskSize, + DiskSizeGb: diskSize, } inst.Disks = []*compute.AttachedDisk{ From 73523877208ba9f80ce398b7fbb301dc4621d3ac Mon Sep 17 00:00:00 2001 From: Pavel Dotsulenko Date: Fri, 31 Jan 2020 16:05:04 +0200 Subject: [PATCH 2/2] Use DISK_SIZE as a default value for DISK_SIZE_WINDOWS --- backend/gce.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/gce.go b/backend/gce.go index 19ffd696f..f2dace457 100644 --- a/backend/gce.go +++ b/backend/gce.go @@ -374,7 +374,7 @@ func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) { } } - diskSizeWindows := defaultGCEDiskSize + diskSizeWindows := diskSize if cfg.IsSet("DISK_SIZE_WINDOWS") { ds, err := strconv.ParseInt(cfg.Get("DISK_SIZE_WINDOWS"), 10, 64) if err == nil {