diff --git a/cmd/unikraft/main_test.go b/cmd/unikraft/main_test.go index 1a874b3a..0723b03d 100644 --- a/cmd/unikraft/main_test.go +++ b/cmd/unikraft/main_test.go @@ -212,12 +212,6 @@ func (b *testBuilder) run(t *testing.T, commands []command) { cmd.Env = append(cmd.Env, "BUILDKIT_PROGRESS=quiet") cmd.Env = append(cmd.Env, resource.UnikraftSandboxEnv+"="+sandboxPath) - if i > 0 { - // HACK: this is awful, but the platform can take a moment for things to - // get ready :( - time.Sleep(500 * time.Millisecond) - } - err := cmd.Run() if command.captureEnv != "" { value := strings.TrimSpace(stdout.String()) diff --git a/cmd/unikraft/testdata/TestGolden/instances/help b/cmd/unikraft/testdata/TestGolden/instances/help index 2bbd8a39..77ac63ee 100644 --- a/cmd/unikraft/testdata/TestGolden/instances/help +++ b/cmd/unikraft/testdata/TestGolden/instances/help @@ -49,7 +49,6 @@ stdout: restart, restart.policy, restart.start-count, restart.restart-count autostart replicas - wait-timeout features vsock stop, stop.reason, stop.origin, stop.errno, stop.exit-code @@ -108,7 +107,6 @@ stdout: restart, restart.policy, restart.start-count, restart.restart-count autostart replicas - wait-timeout features vsock stop, stop.reason, stop.origin, stop.errno, stop.exit-code @@ -175,7 +173,6 @@ stdout: restart, restart.policy, restart.start-count, restart.restart-count autostart replicas - wait-timeout features vsock stop, stop.reason, stop.origin, stop.errno, stop.exit-code @@ -242,7 +239,6 @@ stdout: restart, restart.policy, restart.start-count, restart.restart-count autostart replicas - wait-timeout features vsock stop, stop.reason, stop.origin, stop.errno, stop.exit-code @@ -317,7 +313,6 @@ stdout: restart, restart.policy, restart.start-count, restart.restart-count autostart replicas - wait-timeout features vsock stop, stop.reason, stop.origin, stop.errno, stop.exit-code @@ -437,7 +432,6 @@ stdout: restart, restart.policy, restart.start-count, restart.restart-count autostart replicas - wait-timeout features vsock stop, stop.reason, stop.origin, stop.errno, stop.exit-code @@ -535,7 +529,6 @@ stdout: restart, restart.policy, restart.start-count, restart.restart-count autostart replicas - wait-timeout features vsock stop, stop.reason, stop.origin, stop.errno, stop.exit-code diff --git a/go.mod b/go.mod index d3495dbb..c44d81c0 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,7 @@ require ( gotest.tools/v3 v3.5.2 mvdan.cc/sh/v3 v3.13.0 sigs.k8s.io/yaml v1.6.0 - unikraft.com/cloud/sdk v0.0.0-20260408135319-27c8a525f615 + unikraft.com/cloud/sdk v0.0.0-20260410093415-4a305de2be28 unikraft.com/x/colors v0.0.0-20260313145522-d793c36d706e unikraft.com/x/fingerprint v0.0.0-20260126094137-ab6e717e5679 unikraft.com/x/guesstermwidth v0.0.0-20260304162956-523940cab1de diff --git a/go.sum b/go.sum index e0588d18..c1c765cc 100644 --- a/go.sum +++ b/go.sum @@ -454,8 +454,10 @@ sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4= tailscale.com v1.94.1 h1:0dAst/ozTuFkgmxZULc3oNwR9+qPIt5ucvzH7kaM0Jw= tailscale.com v1.94.1/go.mod h1:gLnVrEOP32GWvroaAHHGhjSGMPJ1i4DvqNwEg+Yuov4= -unikraft.com/cloud/sdk v0.0.0-20260408135319-27c8a525f615 h1:G8Y+c4bcm3bN5alfX66WhV3wrJfcIf5s6WStjIyEvlo= -unikraft.com/cloud/sdk v0.0.0-20260408135319-27c8a525f615/go.mod h1:k4SxfgQFvFmUrBPVIMlU1eYPId9lCkO9/6J9o1sL08s= +unikraft.com/cloud/sdk v0.0.0-20260409121557-1159639ea4e0 h1:ubn0DJHMIEStyubwa1Pi5r6kgQ8lSCtSPyU7kom2bEY= +unikraft.com/cloud/sdk v0.0.0-20260409121557-1159639ea4e0/go.mod h1:k4SxfgQFvFmUrBPVIMlU1eYPId9lCkO9/6J9o1sL08s= +unikraft.com/cloud/sdk v0.0.0-20260410093415-4a305de2be28 h1:33typZqfrAK86//f/gdJBd5FDIV2U0a2edxFfkfQP9k= +unikraft.com/cloud/sdk v0.0.0-20260410093415-4a305de2be28/go.mod h1:k4SxfgQFvFmUrBPVIMlU1eYPId9lCkO9/6J9o1sL08s= unikraft.com/x/colors v0.0.0-20260313145522-d793c36d706e h1:C/V6l4ut5XpcVTN5CvnskRv6NHDbyIeLdgFVLEJ9BIE= unikraft.com/x/colors v0.0.0-20260313145522-d793c36d706e/go.mod h1:SVlAGfyQ7MwJom7m9M2w83+TrO+nJoiLxeduJAxagEo= unikraft.com/x/fingerprint v0.0.0-20260126094137-ab6e717e5679 h1:zdvJjNkjsriS8RM46FcdgcRoCh4EYM66PGjqVgi/ups= diff --git a/internal/cmd/instances.go b/internal/cmd/instances.go index 04bbb8e0..f6b4cde3 100644 --- a/internal/cmd/instances.go +++ b/internal/cmd/instances.go @@ -170,11 +170,10 @@ type Instance struct { RestartCount int `mirror:"instance.restart_count"` } - Autostart bool `field:"autostart,invisible,valueless" create:"set"` - Replicas int64 `field:"replicas,invisible,valueless" create:"set"` - WaitTimeout types.DurationS `field:"wait-timeout,invisible,valueless" create:"set"` - Features []string `field:"features,invisible,valueless" create:"set"` - Vsock bool `field:"vsock,invisible,valueless" create:"set" edit:"set"` + Autostart bool `field:"autostart,invisible,valueless" create:"set"` + Replicas int64 `field:"replicas,invisible,valueless" create:"set"` + Features []string `field:"features,invisible,valueless" create:"set"` + Vsock bool `field:"vsock,invisible,valueless" create:"set" edit:"set"` Stop struct { Reason string `field:",long"` @@ -594,7 +593,15 @@ func (Instance) Delete(ctx context.Context, targets []resource.Resource) error { } return group.DoRefs(ctx, g, keys.Refs(), func(ctx context.Context, c multimetro.MetroClient, refs group.Refs) (group.Refs, error) { log.G(ctx).Trace().Msg("deleting instances") - instances, err := c.DeleteInstances(ctx, refs.NameOrUUIDs(), platform.DeleteInstancesOpts{}) + reqs := make([]platform.DeleteInstanceRequestItem, 0, len(refs)) + for _, ref := range refs.NameOrUUIDs() { + reqs = append(reqs, platform.DeleteInstanceRequestItem{ + Name: ref.Name, + Uuid: ref.Uuid, + TimeoutS: ptr.ToPtr(int64(-1)), + }) + } + instances, err := c.DeleteInstances(ctx, reqs) if err != nil && !platform.ErrorContainsOnly(err, platform.APIHTTPErrorNotFound) { return nil, err } @@ -709,7 +716,7 @@ func instancePatchSpec(path string, op patchOp, value any) (platform.UpdateInsta } func (Instance) Create(ctx context.Context, fields []resource.Field) ([]resource.Resource, error) { - var req platform.CreateInstanceRequest + req := platform.CreateInstanceRequest{} var metro string for key, field := range resource.IterFields(fields) { if field.Create == nil || field.Create.Set == nil { @@ -831,12 +838,12 @@ func (Instance) Create(ctx context.Context, fields []resource.Field) ([]resource case "autostart": autostart := field.Create.Set.(bool) req.Autostart = &autostart + if autostart { + req.TimeoutS = new(int64(-1)) + } case "replicas": replicas := field.Create.Set.(int64) req.Replicas = &replicas - case "wait-timeout": - timeout := field.Create.Set.(types.DurationS) - req.TimeoutS = new(int64(timeout)) case "features": features := field.Create.Set.([]string) for _, f := range features { @@ -1267,8 +1274,9 @@ func startInstances(ctx context.Context, g *group.Group[multimetro.MetroClient], reqs := make([]platform.StartInstancesRequestItem, 0, len(refs)) for _, ref := range refs.NameOrUUIDs() { reqs = append(reqs, platform.StartInstancesRequestItem{ - Name: ref.Name, - Uuid: ref.Uuid, + Name: ref.Name, + Uuid: ref.Uuid, + TimeoutS: ptr.ToPtr(int64(-1)), }) } resp, err := c.StartInstances(ctx, reqs) diff --git a/internal/resource/sandbox.go b/internal/resource/sandbox.go index 4dfe1733..5e35481e 100644 --- a/internal/resource/sandbox.go +++ b/internal/resource/sandbox.go @@ -12,7 +12,6 @@ import ( "fmt" "os" "slices" - "time" "unikraft.com/cloud/sdk/platform/group" "unikraft.com/x/log" @@ -133,10 +132,6 @@ func (s *Sandbox) Teardown(ctx context.Context) (rerr error) { continue } - // HACK: this is awful, but the platform can take a moment for things to - // get ready :( - time.Sleep(500 * time.Millisecond) - resources, err := r.Get(ctx, targets) if err != nil { var notFoundErr group.ErrRefNotFound