From 009315f7208df39036fe2bac7c9b2ec910e6a5c6 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 8 Aug 2025 11:30:11 +0200 Subject: pkg/gce: set minimum disk size for C4A instances It must be more than 10GB. --- pkg/gce/gce.go | 11 +++++++++++ pkg/gce/gce_test.go | 5 +++++ 2 files changed, 16 insertions(+) (limited to 'pkg/gce') 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")) +} -- cgit mrf-deployment