Skip to content

Commit 8d31ff9

Browse files
committed
filter out AZs where not all flavors are available
1 parent 18e82bf commit 8d31ff9

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

internal/pkg/services/ske/utils/utils.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"maps"
77
"os"
88
"path/filepath"
9+
"regexp"
910
"strconv"
1011

1112
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
@@ -109,9 +110,13 @@ func getDefaultPayloadNodepool(resp *ske.ProviderOptions) (*ske.Nodepool, error)
109110
if resp.AvailabilityZones == nil || len(*resp.AvailabilityZones) == 0 {
110111
return nil, fmt.Errorf("no availability zones found")
111112
}
112-
availabilityZones := make([]string, len(*resp.AvailabilityZones))
113+
var availabilityZones []string
113114
for i := range *resp.AvailabilityZones {
114-
availabilityZones[i] = (*resp.AvailabilityZones)[i].GetName()
115+
azName := (*resp.AvailabilityZones)[i].GetName()
116+
// don't include availability zones like eu01-m, eu02-m, not all flavors are available there
117+
if !regexp.MustCompile(`\w{2}\d{2}-m`).MatchString(azName) {
118+
availabilityZones = append(availabilityZones, azName)
119+
}
115120
}
116121

117122
if resp.MachineTypes == nil || len(*resp.MachineTypes) == 0 {

internal/pkg/services/ske/utils/utils_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ func fixtureGetDefaultPayload(mods ...func(*ske.CreateOrUpdateClusterPayload)) *
274274
Nodepools: &[]ske.Nodepool{
275275
{
276276
AvailabilityZones: &[]string{
277-
"eu01-m",
278277
"eu01-1",
279278
"eu01-2",
280279
"eu01-3",
@@ -289,9 +288,9 @@ func fixtureGetDefaultPayload(mods ...func(*ske.CreateOrUpdateClusterPayload)) *
289288
Name: utils.Ptr("flatcar"),
290289
},
291290
},
292-
MaxSurge: utils.Ptr(int64(4)),
291+
MaxSurge: utils.Ptr(int64(3)),
293292
MaxUnavailable: utils.Ptr(int64(0)),
294-
Maximum: utils.Ptr(int64(4)),
293+
Maximum: utils.Ptr(int64(3)),
295294
Minimum: utils.Ptr(int64(1)),
296295
Name: utils.Ptr("pool-default"),
297296
Volume: &ske.Volume{

0 commit comments

Comments
 (0)