Skip to content

Commit 11b2a66

Browse files
jmcarpJosh Carp
andauthored
misc: updates to run simulated omicron in container (#8996)
In oxidecomputer/terraform-provider-oxide#497, we're proposing to run the acceptance tests for the terraform provider against simulated omicron. We're running omicron in a docker container for portability. This PR contains a few small script changes to omicron to make it work in a container: * Optionally skip sudo, since some container environments don't include it. * Update the example config to listen on 0.0.0.0, so that we can reach simulated omicron from outside the container. --------- Co-authored-by: Josh Carp <[email protected]>
1 parent 090c778 commit 11b2a66

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

dev-tools/omicron-dev/src/main.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ use nexus_config::NexusConfig;
1212
use nexus_test_interface::NexusServer;
1313
use nexus_test_utils::resource_helpers::DiskTest;
1414
use signal_hook_tokio::Signals;
15+
use std::fs;
16+
17+
const DEFAULT_NEXUS_CONFIG: &str =
18+
concat!(env!("CARGO_MANIFEST_DIR"), "/../../nexus/examples/config.toml");
1519

1620
fn main() -> anyhow::Result<()> {
1721
oxide_tokio_rt::run(async {
@@ -50,6 +54,9 @@ struct RunAllArgs {
5054
/// Override the gateway server configuration file.
5155
#[clap(long, default_value = DEFAULT_SP_SIM_CONFIG)]
5256
gateway_config: Utf8PathBuf,
57+
/// Override the nexus configuration file.
58+
#[clap(long, default_value = DEFAULT_NEXUS_CONFIG)]
59+
nexus_config: Utf8PathBuf,
5360
}
5461

5562
impl RunAllArgs {
@@ -60,9 +67,10 @@ impl RunAllArgs {
6067
let mut signal_stream = signals.fuse();
6168

6269
// Read configuration.
63-
let config_str = include_str!("../../../nexus/examples/config.toml");
64-
let mut config: NexusConfig =
65-
toml::from_str(config_str).context("parsing example config")?;
70+
let config_str = fs::read_to_string(&self.nexus_config)?;
71+
let mut config: NexusConfig = toml::from_str(&config_str).context(
72+
format!("parsing config: {}", self.nexus_config.as_str()),
73+
)?;
6674
config.pkg.log = dropshot::ConfigLogging::File {
6775
// See LogContext::new(),
6876
path: "UNUSED".to_string().into(),

tools/install_builder_prerequisites.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ function usage
3131

3232
ASSUME_YES="false"
3333
SKIP_PATH_CHECK="false"
34+
OMIT_SUDO="false"
3435
RETRY_ATTEMPTS=3
35-
while getopts ypr: flag
36+
while getopts ypsr: flag
3637
do
3738
case "${flag}" in
3839
y) ASSUME_YES="true" ;;
3940
p) SKIP_PATH_CHECK="true" ;;
41+
s) OMIT_SUDO="true" ;;
4042
r) RETRY_ATTEMPTS=${OPTARG} ;;
4143
*) usage
4244
esac
@@ -130,11 +132,16 @@ function install_packages {
130132
'libclang-dev'
131133
'libsqlite3-dev'
132134
)
133-
sudo apt-get update
135+
if [[ "${OMIT_SUDO}" == "false" ]]; then
136+
maybe_sudo="sudo"
137+
else
138+
maybe_sudo=""
139+
fi
140+
$maybe_sudo apt-get update
134141
if [[ "${ASSUME_YES}" == "true" ]]; then
135-
sudo apt-get install -y "${packages[@]}"
142+
$maybe_sudo apt-get install -y "${packages[@]}"
136143
else
137-
confirm "Install (or update) [${packages[*]}]?" && sudo apt-get install "${packages[@]}"
144+
confirm "Install (or update) [${packages[*]}]?" && $maybe_sudo apt-get install "${packages[@]}"
138145
fi
139146
elif [[ "${HOST_OS}" == "SunOS" ]]; then
140147
CLANGVER=15

tools/install_runner_prerequisites.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ function usage
3030
}
3131

3232
ASSUME_YES="false"
33+
OMIT_SUDO="false"
3334
RETRY_ATTEMPTS=3
34-
while getopts ypr: flag
35+
while getopts ypsr: flag
3536
do
3637
case "${flag}" in
3738
y) ASSUME_YES="true" ;;
3839
p) continue ;;
40+
s) OMIT_SUDO="true" ;;
3941
r) RETRY_ATTEMPTS=${OPTARG} ;;
4042
*) usage
4143
esac
@@ -139,11 +141,16 @@ function install_packages {
139141
'libssl3'
140142
'libxmlsec1-openssl'
141143
)
142-
sudo apt-get update
144+
if [[ "${OMIT_SUDO}" == "false" ]]; then
145+
maybe_sudo="sudo"
146+
else
147+
maybe_sudo=""
148+
fi
149+
$maybe_sudo apt-get update
143150
if [[ "${ASSUME_YES}" == "true" ]]; then
144-
sudo apt-get install -y "${packages[@]}"
151+
$maybe_sudo apt-get install -y "${packages[@]}"
145152
else
146-
confirm "Install (or update) [${packages[*]}]?" && sudo apt-get install "${packages[@]}"
153+
confirm "Install (or update) [${packages[*]}]?" && $maybe_sudo apt-get install "${packages[@]}"
147154
fi
148155
else
149156
echo "Unsupported OS: ${HOST_OS}"

0 commit comments

Comments
 (0)