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

Cleanup confusion arising from mixing of unix exit codes and Rust Result types #4261

Merged
merged 4 commits into from
Nov 24, 2023

Commits on Nov 23, 2023

  1. fix: Eliminate MainError::MicrovmStoppedWithoutError

    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>
    roypat committed Nov 23, 2023
    Configuration menu
    Copy the full SHA
    259c8b8 View commit details
    Browse the repository at this point in the history
  2. fix: Give build_microvm_from_requests a proper error type

    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>
    roypat committed Nov 23, 2023
    Configuration menu
    Copy the full SHA
    33ff7b0 View commit details
    Browse the repository at this point in the history

Commits on Nov 24, 2023

  1. fix: Ensure to exit with error if any vcpu exits with error

    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>
    roypat committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    31323f9 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f4b8353 View commit details
    Browse the repository at this point in the history