Skip to content

Commit 4bcc0e3

Browse files
authored
feat(instance): use sbs images from marketplace on server create (#4466)
1 parent 7c6d626 commit 4bcc0e3

File tree

165 files changed

+45739
-62495
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+45739
-62495
lines changed

internal/namespaces/instance/v1/custom_image_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
func Test_ImageCreate(t *testing.T) {
1515
t.Run("Create simple image", core.Test(&core.TestConfig{
1616
BeforeFunc: core.BeforeFuncCombine(
17-
createServer("Server"),
17+
core.ExecStoreBeforeCmd("Server", testServerCommand("stopped=true image=ubuntu-jammy root-volume=l:20G")),
1818
core.ExecStoreBeforeCmd("Snapshot", `scw instance snapshot create volume-id={{ (index .Server.Volumes "0").ID }}`),
1919
),
2020
Commands: instance.GetCommands(),
@@ -77,7 +77,7 @@ func Test_ImageDelete(t *testing.T) {
7777

7878
func createImage(metaKey string) core.BeforeFunc {
7979
return core.BeforeFuncCombine(
80-
createServer("Server"),
80+
core.ExecStoreBeforeCmd("Server", testServerCommand("stopped=true image=ubuntu-jammy root-volume=l:20G")),
8181
core.ExecStoreBeforeCmd("Snapshot", `scw instance snapshot create volume-id={{ (index .Server.Volumes "0").ID }}`),
8282
core.ExecStoreBeforeCmd(metaKey, `scw instance image create snapshot-id={{ .Snapshot.Snapshot.ID }} arch=x86_64`),
8383
)

internal/namespaces/instance/v1/custom_server_create_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (sb *ServerBuilder) isWindows() bool {
120120

121121
func (sb *ServerBuilder) rootVolumeIsSBS() bool {
122122
if sb.rootVolume == nil {
123-
return false
123+
return true // Default to SBS if no volume type is requested. Local SSD is now only on explicit request.
124124
}
125125

126126
return sb.rootVolume.VolumeType == instance.VolumeVolumeTypeSbsVolume

internal/namespaces/instance/v1/custom_server_create_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,42 +43,42 @@ func Test_CreateServer(t *testing.T) {
4343

4444
t.Run("GP1-XS", core.Test(&core.TestConfig{
4545
Commands: instance.GetCommands(),
46-
Cmd: "scw instance server create type=GP1-XS image=ubuntu_bionic stopped=true",
46+
Cmd: "scw instance server create type=GP1-XS image=ubuntu_jammy stopped=true",
4747
Check: core.TestCheckCombine(
48+
core.TestCheckExitCode(0),
4849
func(t *testing.T, ctx *core.CheckFuncCtx) {
4950
t.Helper()
5051
assert.NotNil(t, ctx.Result)
5152
assert.Equal(t, "GP1-XS", ctx.Result.(*instanceSDK.Server).CommercialType)
5253
},
53-
core.TestCheckExitCode(0),
5454
),
5555
AfterFunc: deleteServerAfterFunc(),
5656
}))
5757

5858
t.Run("With name", core.Test(&core.TestConfig{
5959
Commands: instance.GetCommands(),
60-
Cmd: testServerCommand("image=ubuntu_bionic name=yo stopped=true"),
60+
Cmd: testServerCommand("image=ubuntu_jammy name=yo stopped=true"),
6161
Check: core.TestCheckCombine(
62+
core.TestCheckExitCode(0),
6263
func(t *testing.T, ctx *core.CheckFuncCtx) {
6364
t.Helper()
6465
assert.NotNil(t, ctx.Result)
6566
assert.Equal(t, "yo", ctx.Result.(*instanceSDK.Server).Name)
6667
},
67-
core.TestCheckExitCode(0),
6868
),
6969
AfterFunc: deleteServerAfterFunc(),
7070
}))
7171

7272
t.Run("With start", core.Test(&core.TestConfig{
7373
Commands: instance.GetCommands(),
74-
Cmd: testServerCommand("image=ubuntu_bionic -w"),
74+
Cmd: testServerCommand("image=ubuntu_jammy -w"),
7575
Check: core.TestCheckCombine(
76+
core.TestCheckExitCode(0),
7677
func(t *testing.T, ctx *core.CheckFuncCtx) {
7778
t.Helper()
7879
assert.NotNil(t, ctx.Result)
7980
assert.Equal(t, instanceSDK.ServerStateRunning, ctx.Result.(*instanceSDK.Server).State)
8081
},
81-
core.TestCheckExitCode(0),
8282
),
8383
AfterFunc: deleteServerAfterFunc(),
8484
}))
@@ -99,15 +99,15 @@ func Test_CreateServer(t *testing.T) {
9999

100100
t.Run("Tags", core.Test(&core.TestConfig{
101101
Commands: instance.GetCommands(),
102-
Cmd: testServerCommand("image=ubuntu_bionic tags.0=prod tags.1=blue stopped=true"),
102+
Cmd: testServerCommand("image=ubuntu_jammy tags.0=prod tags.1=blue stopped=true"),
103103
Check: core.TestCheckCombine(
104+
core.TestCheckExitCode(0),
104105
func(t *testing.T, ctx *core.CheckFuncCtx) {
105106
t.Helper()
106107
assert.NotNil(t, ctx.Result)
107108
assert.Equal(t, "prod", ctx.Result.(*instanceSDK.Server).Tags[0])
108109
assert.Equal(t, "blue", ctx.Result.(*instanceSDK.Server).Tags[1])
109110
},
110-
core.TestCheckExitCode(0),
111111
),
112112
AfterFunc: deleteServerAfterFunc(),
113113
}))
@@ -226,7 +226,7 @@ func Test_CreateServer(t *testing.T) {
226226

227227
t.Run("valid additional block volumes", core.Test(&core.TestConfig{
228228
Commands: instance.GetCommands(),
229-
Cmd: testServerCommand("image=ubuntu_bionic additional-volumes.0=b:1G additional-volumes.1=b:5G additional-volumes.2=b:10G stopped=true"),
229+
Cmd: testServerCommand("image=ubuntu_jammy additional-volumes.0=b:1G additional-volumes.1=b:5G additional-volumes.2=b:10G stopped=true"),
230230
Check: core.TestCheckCombine(
231231
core.TestCheckExitCode(0),
232232
testServerSBSVolumeSize("1", 1),
@@ -365,7 +365,7 @@ func Test_CreateServer(t *testing.T) {
365365
t.Run("IPs", func(t *testing.T) {
366366
t.Run("explicit new IP", core.Test(&core.TestConfig{
367367
Commands: instance.GetCommands(),
368-
Cmd: testServerCommand("image=ubuntu_bionic ip=new stopped=true"),
368+
Cmd: testServerCommand("ip=new stopped=true"),
369369
Check: core.TestCheckCombine(
370370
func(t *testing.T, ctx *core.CheckFuncCtx) {
371371
t.Helper()
@@ -382,7 +382,7 @@ func Test_CreateServer(t *testing.T) {
382382

383383
t.Run("run with dynamic IP", core.Test(&core.TestConfig{
384384
Commands: instance.GetCommands(),
385-
Cmd: testServerCommand("image=ubuntu_bionic ip=dynamic -w"), // dynamic IP is created at runtime
385+
Cmd: testServerCommand("ip=dynamic -w"), // dynamic IP is created at runtime
386386
Check: core.TestCheckCombine(
387387
func(t *testing.T, ctx *core.CheckFuncCtx) {
388388
t.Helper()
@@ -401,7 +401,7 @@ func Test_CreateServer(t *testing.T) {
401401
t.Run("existing IP", core.Test(&core.TestConfig{
402402
Commands: instance.GetCommands(),
403403
BeforeFunc: createIP("IP"),
404-
Cmd: testServerCommand("image=ubuntu_bionic ip={{ .IP.Address }} stopped=true"),
404+
Cmd: testServerCommand("ip={{ .IP.Address }} stopped=true"),
405405
Check: core.TestCheckCombine(
406406
func(t *testing.T, ctx *core.CheckFuncCtx) {
407407
t.Helper()
@@ -419,7 +419,7 @@ func Test_CreateServer(t *testing.T) {
419419
t.Run("existing IP ID", core.Test(&core.TestConfig{
420420
Commands: instance.GetCommands(),
421421
BeforeFunc: createIP("IP"),
422-
Cmd: testServerCommand("image=ubuntu_bionic ip={{ .IP.ID }} stopped=true"),
422+
Cmd: testServerCommand("ip={{ .IP.ID }} stopped=true"),
423423
Check: core.TestCheckCombine(
424424
func(t *testing.T, ctx *core.CheckFuncCtx) {
425425
t.Helper()
@@ -436,7 +436,7 @@ func Test_CreateServer(t *testing.T) {
436436

437437
t.Run("with ipv6", core.Test(&core.TestConfig{
438438
Commands: instance.GetCommands(),
439-
Cmd: testServerCommand("image=ubuntu_bionic ip=ipv6 dynamic-ip-required=false -w"), // IPv6 is created at runtime
439+
Cmd: testServerCommand("ip=ipv6 dynamic-ip-required=false -w"), // IPv6 is created at runtime
440440
Check: core.TestCheckCombine(
441441
func(t *testing.T, ctx *core.CheckFuncCtx) {
442442
t.Helper()
@@ -452,7 +452,7 @@ func Test_CreateServer(t *testing.T) {
452452

453453
t.Run("with ipv6 and dynamic ip", core.Test(&core.TestConfig{
454454
Commands: instance.GetCommands(),
455-
Cmd: testServerCommand("image=ubuntu_bionic dynamic-ip-required=true ip=ipv6 -w"), // IPv6 is created at runtime
455+
Cmd: testServerCommand("dynamic-ip-required=true ip=ipv6 -w"), // IPv6 is created at runtime
456456
Check: core.TestCheckCombine(
457457
core.TestCheckExitCode(0),
458458
func(t *testing.T, ctx *core.CheckFuncCtx) {
@@ -470,7 +470,7 @@ func Test_CreateServer(t *testing.T) {
470470

471471
t.Run("with ipv6 and ipv4", core.Test(&core.TestConfig{
472472
Commands: instance.GetCommands(),
473-
Cmd: testServerCommand("image=ubuntu_bionic ip=both -w"), // IPv6 is created at runtime
473+
Cmd: testServerCommand("ip=both -w"), // IPv6 is created at runtime
474474
Check: core.TestCheckCombine(
475475
core.TestCheckExitCode(0),
476476
func(t *testing.T, ctx *core.CheckFuncCtx) {
@@ -573,7 +573,7 @@ func Test_CreateServerErrors(t *testing.T) {
573573

574574
t.Run("Error: invalid total local volumes size: too high 2", core.Test(&core.TestConfig{
575575
Commands: instance.GetCommands(),
576-
Cmd: testServerCommand("image=ubuntu_jammy additional-volumes.0=local:20GB"),
576+
Cmd: testServerCommand("image=ubuntu_jammy additional-volumes.0=local:30GB"),
577577
Check: core.TestCheckCombine(
578578
core.TestCheckGolden(),
579579
core.TestCheckExitCode(1),

internal/namespaces/instance/v1/custom_server_ssh_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func Test_ServerSSH(t *testing.T) {
4848

4949
t.Run("Stopped server", core.Test(&core.TestConfig{
5050
Commands: instance.GetCommands(),
51-
BeforeFunc: createServerBionic("Server"),
51+
BeforeFunc: createServer("Server"),
5252
Cmd: "scw instance server ssh {{ .Server.ID }}",
5353
Check: core.TestCheckCombine(
5454
core.TestCheckGolden(),

0 commit comments

Comments
 (0)