Skip to content

Commit cb3051e

Browse files
authored
revert: "always force stop when using Virtualization.framework" (runfinch#370)
This reverts commit c521f1f. Issue #, if available: After runfinch#368 is merged, the change to always force stop the VM is no longer necessary, since the upstream issue mentioned in runfinch#350 has been fixed in the new version of Lima. *Description of changes:* Undo the changes in runfinch#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]>
1 parent ec20046 commit cb3051e

File tree

2 files changed

+0
-43
lines changed

2 files changed

+0
-43
lines changed

Diff for: cmd/finch/virtual_machine_stop.go

-11
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ func (sva *stopVMAction) runAdapter(cmd *cobra.Command, _ []string) error {
4141
if err != nil {
4242
return err
4343
}
44-
45-
if !force {
46-
if vmType, err := lima.GetVMType(sva.creator, sva.logger, limaInstanceName); err == nil {
47-
if vmType == lima.VZ {
48-
force = true
49-
}
50-
} else {
51-
return err
52-
}
53-
}
54-
5544
return sva.run(force)
5645
}
5746

Diff for: cmd/finch/virtual_machine_stop_test.go

-32
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ func TestStopVMAction_runAdapter(t *testing.T) {
3434
name: "should stop the instance",
3535
args: []string{},
3636
mockSvc: func(logger *mocks.Logger, creator *mocks.LimaCmdCreator, ctrl *gomock.Controller, dm *mocks.UserDataDiskManager) {
37-
getVMTypeC := mocks.NewCommand(ctrl)
38-
creator.EXPECT().CreateWithoutStdio("ls", "-f", "{{.VMType}}", limaInstanceName).Return(getVMTypeC)
39-
getVMTypeC.EXPECT().Output().Return([]byte("qemu"), nil)
40-
logger.EXPECT().Debugf("VMType of virtual machine: %s", "qemu")
41-
4237
getVMStatusC := mocks.NewCommand(ctrl)
4338
creator.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC)
4439
getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil)
@@ -67,33 +62,6 @@ func TestStopVMAction_runAdapter(t *testing.T) {
6762
},
6863
wantErr: nil,
6964
},
70-
{
71-
name: "should stop the instance and use --force even when not specified if VMType == vz",
72-
args: []string{},
73-
mockSvc: func(logger *mocks.Logger, creator *mocks.LimaCmdCreator, ctrl *gomock.Controller, dm *mocks.UserDataDiskManager) {
74-
getVMTypeC := mocks.NewCommand(ctrl)
75-
dm.EXPECT().DetachUserDataDisk().Return(nil)
76-
creator.EXPECT().CreateWithoutStdio("ls", "-f", "{{.VMType}}", limaInstanceName).Return(getVMTypeC)
77-
getVMTypeC.EXPECT().Output().Return([]byte("vz"), nil)
78-
logger.EXPECT().Debugf("VMType of virtual machine: %s", "vz")
79-
80-
command := mocks.NewCommand(ctrl)
81-
creator.EXPECT().CreateWithoutStdio("stop", "--force", limaInstanceName).Return(command)
82-
command.EXPECT().CombinedOutput()
83-
logger.EXPECT().Info(gomock.Any()).AnyTimes()
84-
},
85-
wantErr: nil,
86-
},
87-
{
88-
name: "get VMType returns an error",
89-
args: []string{},
90-
mockSvc: func(_ *mocks.Logger, creator *mocks.LimaCmdCreator, ctrl *gomock.Controller, _ *mocks.UserDataDiskManager) {
91-
getVMTypeC := mocks.NewCommand(ctrl)
92-
creator.EXPECT().CreateWithoutStdio("ls", "-f", "{{.VMType}}", limaInstanceName).Return(getVMTypeC)
93-
getVMTypeC.EXPECT().Output().Return([]byte("unknown"), errors.New("unrecognized VMType"))
94-
},
95-
wantErr: errors.New("unrecognized VMType"),
96-
},
9765
}
9866

9967
for _, tc := range testCases {

0 commit comments

Comments
 (0)