Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: add hyperdisk to supported volume types #228

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .web-docs/components/builder/googlecompute/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,13 @@ source "googlecompute" "example" {
* pd_balanced: persistent, SSD-backed disk
* pd_ssd: persistent, SSD-backed disk, with extra performance guarantees
* pd_extreme: persistent, fastest SSD-backed disk, with custom IOPS
* hyperdisk-balanced: persistent hyperdisk volume, bootable
* hyperdisk-extreme: persistent hyperdisk volume, optimised for performance
* hyperdisk-ml: persistent, shareable, hyperdisk volume, highest throughput
* hyperdisk-throughput: persistent hyperdisk volume with flexible throughput

For details on the different types, refer to: https://cloud.google.com/compute/docs/disks#disk-types
For more information on hyperdisk volumes, refer to: https://cloud.google.com/compute/docs/disks/hyperdisks#throughput

<!-- End of code generated from the comments of the BlockDevice struct in lib/common/block_device.go; -->

Expand Down
5 changes: 5 additions & 0 deletions docs-partials/lib/common/BlockDevice-required.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
* pd_balanced: persistent, SSD-backed disk
* pd_ssd: persistent, SSD-backed disk, with extra performance guarantees
* pd_extreme: persistent, fastest SSD-backed disk, with custom IOPS
* hyperdisk-balanced: persistent hyperdisk volume, bootable
* hyperdisk-extreme: persistent hyperdisk volume, optimised for performance
* hyperdisk-ml: persistent, shareable, hyperdisk volume, highest throughput
* hyperdisk-throughput: persistent hyperdisk volume with flexible throughput

For details on the different types, refer to: https://cloud.google.com/compute/docs/disks#disk-types
For more information on hyperdisk volumes, refer to: https://cloud.google.com/compute/docs/disks/hyperdisks#throughput

<!-- End of code generated from the comments of the BlockDevice struct in lib/common/block_device.go; -->
30 changes: 22 additions & 8 deletions lib/common/block_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ import (
type BlockDeviceType string

const (
LocalScratch BlockDeviceType = "scratch"
ZonalStandard = "pd-standard"
ZonalBalanced = "pd-balanced"
ZonalSSD = "pd-ssd"
ZonalExtreme = "pd-extreme"
LocalScratch BlockDeviceType = "scratch"
ZonalStandard = "pd-standard"
ZonalBalanced = "pd-balanced"
ZonalSSD = "pd-ssd"
ZonalExtreme = "pd-extreme"
HyperDiskBalanced = "hyperdisk-balanced"
HyperDiskExtreme = "hyperdisk-extreme"
HyperDiskML = "hyperdisk-ml"
HyperDiskThroughput = "hyperdisk-throughput"
)

var diskNameRegex = regexp.MustCompile("^[a-z]([-a-z0-9]*[a-z0-9])?$")
Expand Down Expand Up @@ -96,8 +100,13 @@ type BlockDevice struct {
// * pd_balanced: persistent, SSD-backed disk
// * pd_ssd: persistent, SSD-backed disk, with extra performance guarantees
// * pd_extreme: persistent, fastest SSD-backed disk, with custom IOPS
// * hyperdisk-balanced: persistent hyperdisk volume, bootable
// * hyperdisk-extreme: persistent hyperdisk volume, optimised for performance
// * hyperdisk-ml: persistent, shareable, hyperdisk volume, highest throughput
// * hyperdisk-throughput: persistent hyperdisk volume with flexible throughput
//
// For details on the different types, refer to: https://cloud.google.com/compute/docs/disks#disk-types
// For more information on hyperdisk volumes, refer to: https://cloud.google.com/compute/docs/disks/hyperdisks#throughput
VolumeType BlockDeviceType `mapstructure:"volume_type" required:"true"`
// Zone is the zone in which to create the disk in.
//
Expand All @@ -107,12 +116,16 @@ type BlockDevice struct {
}

func volumeTypeError() string {
return fmt.Sprintf("valid volume types are: %s, %s, %s, %s and %s",
return fmt.Sprintf("valid volume types are: %s, %s, %s, %s, %s, %s, %s, %s or %s",
LocalScratch,
ZonalStandard,
ZonalBalanced,
ZonalSSD,
ZonalExtreme)
ZonalExtreme,
HyperDiskBalanced,
HyperDiskExtreme,
HyperDiskML,
HyperDiskThroughput)
}

func (bd *BlockDevice) Prepare() []error {
Expand Down Expand Up @@ -184,7 +197,8 @@ func (bd *BlockDevice) prepareDiskCreate() []error {

switch bd.VolumeType {
case LocalScratch,
ZonalStandard, ZonalBalanced, ZonalSSD, ZonalExtreme:
ZonalStandard, ZonalBalanced, ZonalSSD, ZonalExtreme,
HyperDiskBalanced, HyperDiskExtreme, HyperDiskML, HyperDiskThroughput:
default:
errs = append(errs, fmt.Errorf("A valid volume type was not specified %q", bd.VolumeType))
errs = append(errs, fmt.Errorf("%s", volumeTypeError()))
Expand Down