Skip to content

Commit

Permalink
Merge pull request #6847 from azylinski/machineType-maxDiskSizeGb
Browse files Browse the repository at this point in the history
Extend gce MachineType with MaxDiskSizeGb
  • Loading branch information
k8s-ci-robot committed May 22, 2024
2 parents 696c28c + 840258a commit fda462d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cluster-autoscaler/cloudprovider/gce/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type MachineType struct {
CPU int64
// Memory is the memory capacity of the machine in bytes.
Memory int64
// MaxDisk is the maximum total persistent disks size (GB) allowed.
MaxDiskSizeGb int64
}

// IsCustomMachine checks if a machine type is custom or predefined.
Expand Down Expand Up @@ -70,9 +72,10 @@ func NewMachineTypeFromAPI(name string, mt *gce_api.MachineType) (MachineType, e
return MachineType{}, fmt.Errorf("Failed to create MachineType %s from empty API object", name)
}
return MachineType{
Name: name,
CPU: mt.GuestCpus,
Memory: mt.MemoryMb * units.MiB,
Name: name,
CPU: mt.GuestCpus,
Memory: mt.MemoryMb * units.MiB,
MaxDiskSizeGb: mt.MaximumPersistentDisksSizeGb,
}, nil
}

Expand Down
1 change: 1 addition & 0 deletions cluster-autoscaler/cloudprovider/gce/machine_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func TestNewCustomMachineType(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, tc.expectCPU, m.CPU)
assert.Equal(t, tc.expectMemory, m.Memory)
assert.Equal(t, int64(0), m.MaxDiskSizeGb) // unset
}
})
}
Expand Down

0 comments on commit fda462d

Please sign in to comment.