-
Notifications
You must be signed in to change notification settings - Fork 757
Unify return code framework within the multipass CLI #4567
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: main
Are you sure you want to change the base?
Conversation
Change the return codes of the shell and exec commands to the following paradigm: if there is an internal failure in multipass, the return code is 255, else the return code from the internal VM is returned.
Moved the ssh_channel_get_exit_state function call inside the SSH::throw_on_error wrapper to follow existing standards.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4567 +/- ##
==========================================
+ Coverage 87.18% 87.21% +0.03%
==========================================
Files 247 248 +1
Lines 14273 14290 +17
==========================================
+ Hits 12443 12462 +19
+ Misses 1830 1828 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| }; | ||
| // Only implicitly int-convertible types should be used here. If at least 2 of the same type are | ||
| // used, index-based get<> and holds_alternative<> are needed. | ||
| using ReturnCodeVariant = std::variant<ReturnCode, VMReturnCode>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's it, that's what we need! Thank you so much for taking care of it 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS: not an actual review, just had a light peek
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR unifies the return code framework within the multipass CLI by introducing a variant-based return type system that distinguishes between CLI-side failures (multipass errors) and VM-side return codes. The key changes include:
- Introduction of
ReturnCodeVariantto handle bothReturnCodeandVMReturnCodetypes - Addition of
ShellExecFail(value 255) to distinguish multipass failures from VM exit codes - Migration of
ssh_channel_get_exit_statusto the existing libssh error handling framework - Consistent return type updates across all CLI commands and test files
Reviewed changes
Copilot reviewed 77 out of 77 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| include/multipass/cli/return_codes.h | Introduces VMReturnCode enum and ReturnCodeVariant, adds ShellExecFail code (255), and helper function for variant comparison |
| include/multipass/cli/command.h | Updates command interface to return ReturnCodeVariant instead of ReturnCode |
| include/multipass/ssh/ssh_client.h | Removes unused exec(vector<string>) overload and updates ssh_channel_get_exit_status signature |
| src/ssh/ssh_client.cpp | Refactors to use libssh error framework and returns VM exit codes as VMReturnCode |
| src/client/cli/main.cpp | Converts ReturnCodeVariant to int for process exit code |
| src/client/cli/client.h | Updates run method to return ReturnCodeVariant |
| src/client/cli/cmd/shell.cpp | Returns VMReturnCode for shell exit codes and ShellExecFail for exceptions |
| src/client/cli/cmd/exec.cpp | Returns VMReturnCode for command exit codes and ShellExecFail for exceptions |
| src/client/cli/cmd/*.cpp (multiple) | Updates all command implementations to return ReturnCodeVariant with explicit return type annotations in lambdas |
| src/client/cli/cmd/common_cli.cpp | Updates helper functions for variant-based return codes |
| tests/test_ssh_client.cpp | Updates test expectations for new API signature |
| tests/test_cli_client.cpp | Updates tests for new return codes and variant conversions |
| tests/daemon_test_fixture.cpp | Updates test commands with explicit ReturnCodeVariant return types |
| tests/test_daemon.cpp | Removes unused includes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c856668 to
03a365a
Compare
sharder996
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for tackling this @tobe2098
Description
Related Issue(s)
Closes #4428
Closes #3054
Testing
Unit tests
Manual testing steps:
Checklist
MULTI-2412