diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2025-08-08 11:30:11 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-08-08 11:16:27 +0000 |
| commit | 009315f7208df39036fe2bac7c9b2ec910e6a5c6 (patch) | |
| tree | 57bb2a8e0ff31182d5334b13e5198b19ece43dda /pkg/gce | |
| parent | 265b79936233a0431f3f1032aa207af7f4a6f3c8 (diff) | |
pkg/gce: set minimum disk size for C4A instances
It must be more than 10GB.
Diffstat (limited to 'pkg/gce')
| -rw-r--r-- | pkg/gce/gce.go | 11 | ||||
| -rw-r--r-- | pkg/gce/gce_test.go | 5 |
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")) +} |
