Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Fix vm stop-start with default providers #735

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cmd/ignite/run/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ func Start(so *StartOptions, fs *flag.FlagSet) error {
return fmt.Errorf("VM %q is already running", so.vm.GetUID())
}

// Stopped VMs don't contain the runtime and network information. Set the
// default runtime and network from the providers if empty.
if so.vm.Status.Runtime.Name == "" {
so.vm.Status.Runtime.Name = providers.RuntimeName
}
if so.vm.Status.Network.Plugin == "" {
so.vm.Status.Network.Plugin = providers.NetworkPluginName
}

// In case the runtime and network-plugin are specified explicitly at
// start, set the runtime and network-plugin on the VM. This overrides the
// global config and config on the VM object, if any.
Expand Down
30 changes: 30 additions & 0 deletions e2e/vm_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,33 @@ func TestVMStartNonDefaultProvider(t *testing.T) {
gotInspect := strings.TrimSpace(string(inspectOut))
assert.Equal(t, gotInspect, wantInspect, fmt.Sprintf("unexpected VM properties:\n\t(WNT): %q\n\t(GOT): %q", wantInspect, gotInspect))
}

func TestVMStopStartDefaultProviders(t *testing.T) {
assert.Assert(t, e2eHome != "", "IGNITE_E2E_HOME should be set")

vmName := "e2e-test-vm-stop-start-default-providers"

igniteCmd := util.NewCommand(t, igniteBin)

// Clean-up the following VM.
defer igniteCmd.New().
With("rm", "-f", vmName).
Run()

// Run the VM.
igniteCmd.New().
With("run").
With(util.DefaultVMImage).
With("--name=" + vmName).
Run()

// Stop the VM.
igniteCmd.New().
With("stop", vmName).
Run()

// Start the VM.
igniteCmd.New().
With("start", vmName).
Run()
}