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

fix: restore the id parameter default #4154

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/firecracker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
.arg(
Argument::new("id")
.takes_value(true)
.default_value(vmm::logger::DEFAULT_INSTANCE_ID)

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

View check run for this annotation

Codecov / codecov/patch

src/firecracker/src/main.rs#L147

Added line #L147 was not covered by tests
.help("MicroVM unique identifier."),
)
.arg(
Expand Down Expand Up @@ -262,8 +263,6 @@
return Ok(());
}

info!("Running Firecracker v{FIRECRACKER_VERSION}");

register_signal_handlers().map_err(MainError::RegisterSignalHandlers)?;

#[cfg(target_arch = "aarch64")]
Expand Down Expand Up @@ -298,11 +297,9 @@
app_name: "Firecracker".to_string(),
};

let id = arguments
.single_value("id")
.map(|s| s.as_str())
.unwrap_or(vmm::logger::DEFAULT_INSTANCE_ID);
let id = arguments.single_value("id").map(|s| s.as_str()).unwrap();

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

View check run for this annotation

Codecov / codecov/patch

src/firecracker/src/main.rs#L300

Added line #L300 was not covered by tests
vmm::logger::INSTANCE_ID.set(String::from(id)).unwrap();
info!("Running Firecracker v{FIRECRACKER_VERSION}");

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

View check run for this annotation

Codecov / codecov/patch

src/firecracker/src/main.rs#L302

Added line #L302 was not covered by tests

// Apply the logger configuration.
let log_path = arguments.single_value("log-path").map(PathBuf::from);
Expand Down
16 changes: 16 additions & 0 deletions tests/integration_tests/functional/test_cmd_line_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""Tests that ensure the correctness of the command line parameters."""

import platform
import subprocess
from pathlib import Path

import pytest
Expand Down Expand Up @@ -130,3 +131,18 @@ def test_cli_metrics_if_resume_no_metrics(uvm_plain, microvm_factory):
# Then: the old metrics configuration does not exist
metrics2 = Path(uvm2.jailer.chroot_path()) / metrics_path.name
assert not metrics2.exists()


def test_cli_no_params():
"""
Test running firecracker with no parameters should work
"""

fc_binary, _ = get_firecracker_binaries()
process = subprocess.Popen(fc_binary)
try:
process.communicate(timeout=3)
assert process.returncode is None
except subprocess.TimeoutExpired:
# The good case
process.kill()