Skip to content

Commit 294265d

Browse files
drewmalinbrianlechthalertylerfong
authored
fix(BREV-2823): Remove hardcoded sfc locations (brevdev#92)
* Add region richmond to stable types, allow instances to be created in any region that's available (brevdev#91) * add richmond region to stable types * don't restrict which zones can be used, allow all zones * fix(BREV-2823): Remove hardcoded sfc locations * remove unused locations * fix set validation test * check for snap and install --------- Co-authored-by: Brian Lechthaler <brianlechthaler@protonmail.ch> Co-authored-by: Tyler Fong <tylerf@nvidia.com>
1 parent bcd0710 commit 294265d

4 files changed

Lines changed: 15 additions & 13 deletions

File tree

v1/instancetype.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ func ValidateLocationalInstanceTypes(ctx context.Context, client CloudInstanceTy
337337
}
338338

339339
// Validate that locational results are a subset of all-location results
340-
if len(locationalTypes) >= len(allLocationTypes) {
341-
return fmt.Errorf("locational instance types (%d) should be fewer than all-location types (%d)",
340+
if len(locationalTypes) > len(allLocationTypes) {
341+
return fmt.Errorf("locational instance types (%d) should not exceed all-location types (%d)",
342342
len(locationalTypes), len(allLocationTypes))
343343
}
344344

v1/networking_validation.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,17 @@ func setupMicroK8sCommand(ctx context.Context, sshClient *ssh.Client, instanceID
491491
_, _, err := sshClient.RunCommand(ctx, checkCmd)
492492
if err != nil {
493493
fmt.Printf("MicroK8s not found or not ready, attempting to install on instance %s\n", instanceID)
494+
495+
// Ensure snap is available, install snapd if not
496+
_, _, snapErr := sshClient.RunCommand(ctx, "snap --version")
497+
if snapErr != nil {
498+
fmt.Printf("snap not found, installing snapd on instance %s\n", instanceID)
499+
_, stderr, installErr := sshClient.RunCommand(ctx, "sudo apt-get update && sudo apt-get install -y snapd")
500+
if installErr != nil {
501+
return "", fmt.Errorf("failed to install snapd: %w, stderr: %s", installErr, stderr)
502+
}
503+
}
504+
494505
_, stderr, installErr := sshClient.RunCommand(ctx, "sudo snap install microk8s --classic")
495506
if installErr != nil {
496507
return "", fmt.Errorf("microk8s not available and failed to install: %w, stderr: %s", installErr, stderr)

v1/providers/sfcompute/instancetype.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package v1
33
import (
44
"context"
55
"fmt"
6-
"slices"
76
"strings"
87
"time"
98

@@ -24,8 +23,6 @@ const (
2423
diskTypeSSD = "ssd"
2524
)
2625

27-
var allowedZones = []string{"hayesvalley", "yerba"}
28-
2926
func makeDefaultInstanceTypePrice(amount string, currencyCode string) currency.Amount {
3027
instanceTypePrice, err := currency.NewAmount(amount, currencyCode)
3128
if err != nil {
@@ -186,12 +183,7 @@ func (c *SFCClient) getZones(ctx context.Context, includeUnavailable bool) ([]sf
186183

187184
zones := make([]sfcnodes.ZoneListResponseData, 0, len(resp.Data))
188185
for _, zone := range resp.Data {
189-
// If the zone is not allowed, skip it
190-
if !slices.Contains(allowedZones, strings.ToLower(zone.Name)) {
191-
continue
192-
}
193-
194-
// If the there is no available capacity, and skip it
186+
// If the there is no available capacity, skip it
195187
if len(zone.AvailableCapacity) == 0 && !includeUnavailable {
196188
continue
197189
}

v1/providers/sfcompute/validation_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ func TestValidationFunctions(t *testing.T) {
1616
config := validation.ProviderConfig{
1717
Credential: NewSFCCredential("validation-test", apiKey),
1818
StableIDs: []v1.InstanceTypeID{
19-
"hayesvalley-noSub-h100",
20-
"yerba-noSub-h100",
19+
"richmond-noSub-h100",
2120
},
2221
}
2322

0 commit comments

Comments
 (0)