aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/gce
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/gce')
-rw-r--r--pkg/gce/gce.go11
-rw-r--r--pkg/gce/gce_test.go5
2 files changed, 16 insertions, 0 deletions
diff --git a/pkg/gce/gce.go b/pkg/gce/gce.go
index c89c474a7..20aee4c7c 100644
--- a/pkg/gce/gce.go
+++ b/pkg/gce/gce.go
@@ -131,6 +131,7 @@ func (ctx *Context) CreateInstance(name, machineType, image, sshkey string,
AutoDelete: true,
Boot: true,
Type: "PERSISTENT",
+ DiskSizeGb: int64(diskSizeGB(machineType)),
InitializeParams: &compute.AttachedDiskInitializeParams{
DiskName: name,
SourceImage: prefix + "/global/images/" + image,
@@ -210,6 +211,16 @@ retry:
return ip, nil
}
+func diskSizeGB(machineType string) int {
+ if strings.HasPrefix(machineType, "c4a-") {
+ // For C4A machines, the only available disk type is "Hyperdisk Balanced",
+ // which must be >= 10GB.
+ return 10
+ }
+ // Use the default value.
+ return 0
+}
+
func (ctx *Context) DeleteInstance(name string, wait bool) error {
var op *compute.Operation
err := ctx.apiCall(func() (err error) {
diff --git a/pkg/gce/gce_test.go b/pkg/gce/gce_test.go
index 39f086bdc..82da75a35 100644
--- a/pkg/gce/gce_test.go
+++ b/pkg/gce/gce_test.go
@@ -19,3 +19,8 @@ func TestZoneToRegion(t *testing.T) {
assert.Equal(t, "us-west1", zoneToRegion("us-west1-b"))
assert.Equal(t, "northamerica-northeast2", zoneToRegion("northamerica-northeast2-a"))
}
+
+func TestDiskSizeGB(t *testing.T) {
+ assert.Equal(t, 10, diskSizeGB("c4a-standard-2"))
+ assert.Equal(t, 0, diskSizeGB("e2-standard-2"))
+}