-
Notifications
You must be signed in to change notification settings - Fork 364
NAS-137987 / 26.04 / fix: call vm.resume on suspended VMs
#13039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
* rename `doStart` to `doStartResume`. it now calls `vm.resume` on a suspended VM instead of `vm.start`. * update usage of `doStart` to `doStartResume` throughout the codebase. * add unit tests to cover the new resume/start functionality.
vm.resume on suspended VMsvm.resume on suspended VMs
|
Claude finished @mattwyatt-ix's task —— View job Code Review Complete ✅Great implementation! The fix correctly addresses the bug where suspended VMs were calling Strong PointsThe implementation is well thought out with proper type safety, comprehensive JSDoc, excellent test coverage including edge cases, and the conditional logic correctly handles the overcommit parameter only for start operations. Issues Found1. Missing Error Test for Resume Operation ❗The test suite covers error scenarios for Suggested test (add to it('should handle error when resuming suspended VM fails', async () => {
const vm = mockVm(VmState.Suspended);
const apiService = spectator.inject(ApiService);
const errorHandlerService = spectator.inject(ErrorHandlerService);
const callSpy = jest.spyOn(apiService, 'call');
const mockImpl = callSpy.getMockImplementation();
callSpy.mockImplementation((method) => {
if (method === 'vm.resume') {
return throwError(() => new ApiCallError({
code: JsonRpcErrorCode.CallError,
message: 'Failed to resume VM'
}));
}
return mockImpl(method);
});
await firstValueFrom(spectator.service.doStartResume(vm));
expect(apiService.call).toHaveBeenCalledWith('vm.resume', [1]);
expect(errorHandlerService.showErrorModal).toHaveBeenCalled();
});2. Type Assertion Could Be Safer 💡In Current code ( type StartResumeParams = ApiCallParams<typeof this.wsMethods.start> | ApiCallParams<typeof this.wsMethods.resume>;
return this.api.call(method, params as StartResumeParams)Suggested improvement: // Type assertion needed: TypeScript can't narrow the union of method/params pairs
type StartResumeParams = ApiCallParams<typeof this.wsMethods.start> | ApiCallParams<typeof this.wsMethods.resume>;
return this.api.call(method, params as StartResumeParams)Minor Observations
Architecture NoteThe PR description mentions an alternate implementation using a separate |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #13039 +/- ##
==========================================
+ Coverage 86.69% 86.71% +0.01%
==========================================
Files 1846 1846
Lines 69371 69373 +2
Branches 8574 8575 +1
==========================================
+ Hits 60143 60156 +13
+ Misses 9228 9217 -11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Changes:
for suspended VMs, we properly displayed that they were suspended and displayed 'Resume' instead of 'Start' on the UI. the problem is that we still called
vm.startinstead ofvm.resume.doStarttodoStartResume. it now callsvm.resumeon a suspended VM instead ofvm.start. the original behavior is unaffected and the correct parameters are passed to both methods.doStarttodoStartResumethroughout the codebase.vm.service.ts.Testing:
see ticket for the original bug behavior.
midclt call vm.suspend <VM_ID>to suspend your VM.Notes:
we could have avoided modifying the
doStartmethod and instead creating adoResumemethod and using it inside the components. this is an alternate implementation that we could consider.Downstream