Skip to content

Commit 4487796

Browse files
authored
feat: make storage tier configurable (#66)
Users can now choose between 'maxiops', 'standard', and 'archive' storage tiers in both builder and post-processor. Signed-off-by: Ville Vesilehto <ville.vesilehto@upcloud.com>
1 parent 853f693 commit 4487796

File tree

13 files changed

+70
-5
lines changed

13 files changed

+70
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)
55

66
## [Unreleased]
77

8+
### Added
9+
10+
- Enable storage tier customisation through `storage_tier` parameter
11+
812
### Fixed
913

1014
- Update Go version to 1.24 and fix security vulnerabilities

builder/upcloud/builder_acc_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ var testBuilderStorageName string
3131
//go:embed test-fixtures/json/networking.json
3232
var testBuilderNetworking string
3333

34+
//go:embed test-fixtures/json/basic_standard_tier.json
35+
var testBuilderBasicStandardTier string
36+
3437
func TestBuilderAcc_default(t *testing.T) {
3538
testAccPreCheck(t)
3639

@@ -65,6 +68,17 @@ func TestBuilderAcc_storageName(t *testing.T) {
6568
acctest.TestPlugin(t, testCase)
6669
}
6770

71+
func TestBuilderAcc_standardTier(t *testing.T) {
72+
testAccPreCheck(t)
73+
testCase := &acctest.PluginTestCase{
74+
Name: t.Name(),
75+
Template: testBuilderBasicStandardTier,
76+
Check: checkTestResult(),
77+
Teardown: teardown(t.Name()),
78+
}
79+
acctest.TestPlugin(t, testCase)
80+
}
81+
6882
func TestBuilderAcc_networking(t *testing.T) {
6983
testAccPreCheck(t)
7084
testCase := &acctest.PluginTestCase{

builder/upcloud/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const (
2424
DefaultCommunicator = "ssh"
2525
DefaultStorageSize = 25
2626
DefaultTimeout = 5 * time.Minute
27+
DefaultStorageTier = upcloud.StorageTierMaxIOPS
2728
InterfaceTypePublic InterfaceType = upcloud.IPAddressAccessPublic
2829
InterfaceTypeUtility InterfaceType = upcloud.IPAddressAccessUtility
2930
InterfaceTypePrivate InterfaceType = upcloud.IPAddressAccessPrivate
@@ -103,6 +104,10 @@ type Config struct {
103104
// The operating system disk can also be later extended if needed. Note that Windows templates require large storage size, than default 25 Gb.
104105
StorageSize int `mapstructure:"storage_size"`
105106

107+
// The storage tier to use. Available options are `maxiops`, `archive`, and `standard`. Defaults to `maxiops`.
108+
// For most production workloads, MaxIOPS is recommended for best performance.
109+
StorageTier string `mapstructure:"storage_tier"`
110+
106111
// The amount of time to wait for resource state changes. Defaults to `5m`.
107112
Timeout time.Duration `mapstructure:"state_timeout_duration"`
108113

@@ -158,6 +163,10 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
158163
c.StorageSize = DefaultStorageSize
159164
}
160165

166+
if c.StorageTier == "" {
167+
c.StorageTier = DefaultStorageTier
168+
}
169+
161170
if c.Timeout == 0 {
162171
c.Timeout = DefaultTimeout
163172
}

builder/upcloud/config.hcl2spec.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

builder/upcloud/step_create_server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func (s *StepCreateServer) Run(ctx context.Context, state multistep.StateBag) mu
4848
Zone: s.Config.Zone,
4949
SshPublicKey: sshKeyPublic,
5050
Networking: networking,
51+
StorageTier: s.Config.StorageTier,
5152
})
5253
if err != nil {
5354
return stepHaltWithError(state, err)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
source "upcloud" "standard-tier" {
2+
storage_uuid = "01000000-0000-4000-8000-000150020100" # Rocky Linux 9
3+
zone = "nl-ams1"
4+
storage_tier = "standard"
5+
}
6+
7+
build {
8+
sources = ["source.upcloud.standard-tier"]
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"builders": [{
3+
"type": "upcloud",
4+
"zone": "nl-ams1",
5+
"storage_uuid": "01000000-0000-4000-8000-000150020100",
6+
"storage_tier": "standard"
7+
}]
8+
}

docs-partials/builder/upcloud/Config-not-required.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
Changing this value is useful if you aim to build a template for larger server configurations where the preconfigured server disk is larger than 25 GB.
1717
The operating system disk can also be later extended if needed. Note that Windows templates require large storage size, than default 25 Gb.
1818

19+
- `storage_tier` (string) - The storage tier to use. Available options are `maxiops`, `archive`, and `standard`. Defaults to `maxiops`.
20+
For most production workloads, MaxIOPS is recommended for best performance.
21+
1922
- `state_timeout_duration` (duration string | ex: "1h5m2s") - The amount of time to wait for resource state changes. Defaults to `5m`.
2023

2124
- `boot_wait` (duration string | ex: "1h5m2s") - The amount of time to wait after booting the server. Defaults to '0s'

example/build.pkr.hcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ source "upcloud" "test" {
3232
zone = "nl-ams1"
3333
storage_name = "ubuntu server 20.04"
3434
template_prefix = "ubuntu-server"
35+
# uncomment to use standard tier storage
36+
# storage_tier = "standard
3537
}
3638

3739
build {

example/import.pkr.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ build {
3535
username = "${var.username}"
3636
password = "${var.password}"
3737
zones = ["pl-waw1", "fi-hel2"]
38+
storage_tier = "maxiops"
3839
}
3940
}
4041
}

0 commit comments

Comments
 (0)