Skip to content

Commit

Permalink
Merge pull request #626 from travis-ci/pd-customize-win-disk-size
Browse files Browse the repository at this point in the history
Allow to set custom disk size for windows
  • Loading branch information
pavel-d authored Jan 31, 2020
2 parents 5eb945f + 9ca1fa7 commit 6d3048d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion backend/gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -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\"",
Expand Down Expand Up @@ -218,6 +219,7 @@ type gceInstanceConfig struct {
Subnetwork *compute.Subnetwork
AcceleratorConfig *compute.AcceleratorConfig
DiskSize int64
DiskSizeWindows int64
SSHPubKey string
AutoImplode bool
HardTimeoutMinutes int64
Expand Down Expand Up @@ -372,6 +374,14 @@ func newGCEProvider(cfg *config.ProviderConfig) (Provider, error) {
}
}

diskSizeWindows := diskSize
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"))
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 6d3048d

Please sign in to comment.