Skip to content

Commit

Permalink
revert: "always force stop when using Virtualization.framework" (#370)
Browse files Browse the repository at this point in the history
This reverts commit c521f1f.

Issue #, if available: After #368 is merged, the change to always force
stop the VM is no longer necessary, since the upstream issue mentioned
in #350 has been fixed in the new version of Lima.

*Description of changes:* Undo the changes in #350

*Testing done:*
- local testing
- unit tests


- [x] I've reviewed the guidance in CONTRIBUTING.md


#### License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

Refs: c521f1f

---------

Signed-off-by: Justin Alvarez <[email protected]>
  • Loading branch information
pendo324 authored Feb 14, 2024
1 parent ec20046 commit cb3051e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 43 deletions.
11 changes: 0 additions & 11 deletions cmd/finch/virtual_machine_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,6 @@ func (sva *stopVMAction) runAdapter(cmd *cobra.Command, _ []string) error {
if err != nil {
return err
}

if !force {
if vmType, err := lima.GetVMType(sva.creator, sva.logger, limaInstanceName); err == nil {
if vmType == lima.VZ {
force = true
}
} else {
return err
}
}

return sva.run(force)
}

Expand Down
32 changes: 0 additions & 32 deletions cmd/finch/virtual_machine_stop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ func TestStopVMAction_runAdapter(t *testing.T) {
name: "should stop the instance",
args: []string{},
mockSvc: func(logger *mocks.Logger, creator *mocks.LimaCmdCreator, ctrl *gomock.Controller, dm *mocks.UserDataDiskManager) {
getVMTypeC := mocks.NewCommand(ctrl)
creator.EXPECT().CreateWithoutStdio("ls", "-f", "{{.VMType}}", limaInstanceName).Return(getVMTypeC)
getVMTypeC.EXPECT().Output().Return([]byte("qemu"), nil)
logger.EXPECT().Debugf("VMType of virtual machine: %s", "qemu")

getVMStatusC := mocks.NewCommand(ctrl)
creator.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC)
getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil)
Expand Down Expand Up @@ -67,33 +62,6 @@ func TestStopVMAction_runAdapter(t *testing.T) {
},
wantErr: nil,
},
{
name: "should stop the instance and use --force even when not specified if VMType == vz",
args: []string{},
mockSvc: func(logger *mocks.Logger, creator *mocks.LimaCmdCreator, ctrl *gomock.Controller, dm *mocks.UserDataDiskManager) {
getVMTypeC := mocks.NewCommand(ctrl)
dm.EXPECT().DetachUserDataDisk().Return(nil)
creator.EXPECT().CreateWithoutStdio("ls", "-f", "{{.VMType}}", limaInstanceName).Return(getVMTypeC)
getVMTypeC.EXPECT().Output().Return([]byte("vz"), nil)
logger.EXPECT().Debugf("VMType of virtual machine: %s", "vz")

command := mocks.NewCommand(ctrl)
creator.EXPECT().CreateWithoutStdio("stop", "--force", limaInstanceName).Return(command)
command.EXPECT().CombinedOutput()
logger.EXPECT().Info(gomock.Any()).AnyTimes()
},
wantErr: nil,
},
{
name: "get VMType returns an error",
args: []string{},
mockSvc: func(_ *mocks.Logger, creator *mocks.LimaCmdCreator, ctrl *gomock.Controller, _ *mocks.UserDataDiskManager) {
getVMTypeC := mocks.NewCommand(ctrl)
creator.EXPECT().CreateWithoutStdio("ls", "-f", "{{.VMType}}", limaInstanceName).Return(getVMTypeC)
getVMTypeC.EXPECT().Output().Return([]byte("unknown"), errors.New("unrecognized VMType"))
},
wantErr: errors.New("unrecognized VMType"),
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit cb3051e

Please sign in to comment.