Skip to content
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

[1.5] Cleanup confusion arising from mixing of unix exit codes and Rust Result types #4271

Merged
merged 4 commits into from
Nov 27, 2023

Conversation

roypat
Copy link
Contributor

@roypat roypat commented Nov 24, 2023

Backport of #4261

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following
Developer Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • If a specific issue led to this PR, this PR closes the issue.
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this PR.
  • API changes follow the Runbook for Firecracker API changes.
  • User-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.
  • New TODOs link to an issue.
  • Commits meet contribution quality standards.

  • This functionality cannot be added in rust-vmm.

@roypat roypat added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Nov 24, 2023
ShadowCurse
ShadowCurse previously approved these changes Nov 24, 2023
Copy link

codecov bot commented Nov 24, 2023

Codecov Report

Attention: 19 lines in your changes are missing coverage. Please review.

Comparison is base (b85d0b7) 82.97% compared to head (f8f446a) 83.00%.

Files Patch % Lines
src/vmm/src/rpc_interface.rs 0.00% 9 Missing ⚠️
src/firecracker/src/api_server_adapter.rs 0.00% 5 Missing ⚠️
src/vmm/src/lib.rs 50.00% 5 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##           firecracker-v1.5    #4271      +/-   ##
====================================================
+ Coverage             82.97%   83.00%   +0.03%     
====================================================
  Files                   223      223              
  Lines                 28471    28459      -12     
====================================================
- Hits                  23623    23622       -1     
+ Misses                 4848     4837      -11     
Flag Coverage Δ
4.14-c7g.metal 78.55% <0.00%> (+0.03%) ⬆️
4.14-m5d.metal 80.34% <20.83%> (+0.03%) ⬆️
4.14-m6a.metal 79.48% <20.83%> (+0.03%) ⬆️
4.14-m6g.metal 78.55% <0.00%> (+0.03%) ⬆️
4.14-m6i.metal 80.33% <20.83%> (+0.03%) ⬆️
5.10-c7g.metal 81.46% <0.00%> (+0.04%) ⬆️
5.10-m5d.metal 83.00% <20.83%> (+0.03%) ⬆️
5.10-m6a.metal 82.25% <20.83%> (+0.03%) ⬆️
5.10-m6g.metal 81.46% <0.00%> (+0.04%) ⬆️
5.10-m6i.metal 83.00% <20.83%> (+0.03%) ⬆️
6.1-c7g.metal 81.46% <0.00%> (+0.04%) ⬆️
6.1-m5d.metal 83.02% <20.83%> (+0.03%) ⬆️
6.1-m6a.metal 82.25% <20.83%> (+0.03%) ⬆️
6.1-m6g.metal 81.46% <0.00%> (+0.04%) ⬆️
6.1-m6i.metal 83.00% <20.83%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This error variant was used to encode that no error actually happened,
which does not make much sense conceptually. What made this worse is
that is contained a FcExitCode, which is itself just a fake Result<(),
non-zero-exit code>. This means it was possible to get Firecracker to
exit with status "error, but not actually error, but actually there is
an error after all", or: "Firecracker exited with an error:
Microvm stopped without an error: GenericError".

The underlying problem here is the fact that we are using `FcExitCode`
as an error variant for `Result`. Since `FcExitCode::Ok` exists,
`FcExitCode` is a kind of `Result` itself, meaning we are dealing with
`Result<_, Result<_, _>>` as a type, which has no well-defined
interpretation.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Using FcExitCode as an error type is undesirable, as it allows us to
construct Err(FcExitCode::Ok), e.g. an object that says "error:
everything's okay!". This is confusing and has caused problems in
different contexts before, so replace FcExitCode with a proper error
type here.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Previously, when a VM exited, we looked for the first vcpu that reported
an exit status, and then indiscriminately reported that back. However,
it is possible to one vcpu to exit successfully while another exits with
an error, and this could lead us to report "Firecracker Exited
Successfully" even though it did not.

Now, we explicitly look for the status code of all vcpus. If any of them
report an error, this takes precedence over non-error status codes.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
CHANGELOG.md Outdated Show resolved Hide resolved
Backported commit with PR number chnaged.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
@pb8o pb8o merged commit d785d60 into firecracker-microvm:firecracker-v1.5 Nov 27, 2023
4 of 7 checks passed
@pb8o pb8o mentioned this pull request Nov 28, 2023
9 tasks
@roypat roypat deleted the backport-4261 branch April 15, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting review Indicates that a pull request is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants