Skip to content

Commit ac15af4

Browse files
author
Jonathan Woollett-Light
committed
fix: Pass through no-API shutdown exit code
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]>
1 parent 00524a7 commit ac15af4

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

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

2629
## [1.5.0]
2730

src/firecracker/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ impl From<MainError> for ExitCode {
8383
MainError::InvalidLogLevel(_) => FcExitCode::BadConfiguration,
8484
MainError::RunWithApi(ApiServerError::MicroVMStoppedWithoutError(code)) => code,
8585
MainError::RunWithApi(ApiServerError::MicroVMStoppedWithError(code)) => code,
86+
MainError::RunWithoutApiError(RunWithoutApiError::Shutdown(code)) => code,
8687
_ => FcExitCode::GenericError,
8788
};
8889

tests/integration_tests/functional/test_cmd_line_start.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import platform
88
import re
99
import shutil
10+
import time
1011
from pathlib import Path
1112

1213
import pytest
@@ -156,6 +157,27 @@ def test_config_start_no_api(uvm_plain, vm_config_file):
156157
)
157158

158159

160+
@pytest.mark.parametrize("vm_config_file", ["framework/vm_config_network.json"])
161+
def test_config_start_no_api_exit(uvm_plain, vm_config_file):
162+
"""
163+
Test microvm exit when API server is disabled.
164+
"""
165+
test_microvm = uvm_plain
166+
_configure_vm_from_json(test_microvm, vm_config_file)
167+
_configure_network_interface(test_microvm)
168+
test_microvm.jailer.extra_args.update({"no-api": None})
169+
170+
test_microvm.spawn() # Start Firecracker and MicroVM
171+
time.sleep(3) # Wait for startup
172+
test_microvm.ssh.run("reboot") # Exit
173+
time.sleep(3) # Wait for shutdown
174+
175+
# Check error log
176+
test_microvm.check_log_message(
177+
"RunWithoutApiError error: MicroVMStopped without an error: Ok"
178+
)
179+
180+
159181
@pytest.mark.parametrize(
160182
"vm_config_file",
161183
[

0 commit comments

Comments
 (0)