Skip to content

Commit

Permalink
fix: Pass through no-API shutdown exit code
Browse files Browse the repository at this point in the history
Without passing through the exit code a non-zero exit code was returned
on a successful no-API shutdown.

Signed-off-by: Jonathan Woollett-Light <[email protected]>
  • Loading branch information
Jonathan Woollett-Light committed Oct 18, 2023
1 parent 00524a7 commit af3383b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

- Fixed a bug that ignored the `--show-log-origin` option, preventing it from
printing the source code file of the log messages.
- [#4178](https://github.com/firecracker-microvm/firecracker/pull/4178):
Fixed a bug reporting a non-zero exit code on successful shutdown when
starting Firecracker with `--no-api`.

## [1.5.0]

Expand Down Expand Up @@ -68,7 +71,7 @@
restore times for medium to large microVMs with many devices attached.
- Changed the dump feature of `cpu-template-helper` tool not to enumerate program
counter (PC) on ARM because it is determined by the given kernel image and
it is useless in the custom CPU template context.
it is useless in the custom CPU templase eth0 here we could later consider this file as a good reference for getting started guide to start Firecracker with network.te context.
- The ability to create snapshots for an older version of Firecracker is now
deprecated. As a result, the `version` body field in `PUT` on
`/snapshot/create` request in deprecated.
Expand Down
1 change: 1 addition & 0 deletions src/firecracker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl From<MainError> for ExitCode {
MainError::InvalidLogLevel(_) => FcExitCode::BadConfiguration,
MainError::RunWithApi(ApiServerError::MicroVMStoppedWithoutError(code)) => code,
MainError::RunWithApi(ApiServerError::MicroVMStoppedWithError(code)) => code,
MainError::RunWithoutApiError(RunWithoutApiError::Shutdown(code)) => code,

Check warning on line 86 in src/firecracker/src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/firecracker/src/main.rs#L86

Added line #L86 was not covered by tests
_ => FcExitCode::GenericError,
};

Expand Down
22 changes: 22 additions & 0 deletions tests/integration_tests/functional/test_cmd_line_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import platform
import re
import shutil
import time
from pathlib import Path

import pytest
Expand Down Expand Up @@ -156,6 +157,27 @@ def test_config_start_no_api(uvm_plain, vm_config_file):
)


@pytest.mark.parametrize("vm_config_file", ["framework/vm_config_network.json"])
def test_config_start_no_api_exit(uvm_plain, vm_config_file):
"""
Test microvm exit when API server is disabled.
"""
test_microvm = uvm_plain
_configure_vm_from_json(test_microvm, vm_config_file)
_configure_network_interface(test_microvm)
test_microvm.jailer.extra_args.update({"no-api": None})

test_microvm.spawn() # Start Firecracker and MicroVM
time.sleep(3) # Wait for startup
test_microvm.ssh.run("reboot") # Exit
time.sleep(3) # Wait for shutdown

# Check error log
test_microvm.check_log_message(
"RunWithoutApiError error: MicroVMStopped without an error: Ok"
)


@pytest.mark.parametrize(
"vm_config_file",
[
Expand Down

0 comments on commit af3383b

Please sign in to comment.