Skip to content

Commit 9ee2e1f

Browse files
iximeowgjcolombo
andauthored
Use production propolis-server flags in PHD CI builds (#878)
We use the dev (e.g. non-release) build of propolis-server in PHD to get debug assertions, which we want, but we should use the `omicron-build` feature to be in line with production binaries. `omicron-build` had also acquired code related to failure injection, which we *also* want in CI so we can test migration failure codepaths. That is moved to a new `failure-injection` feature flag with a bit of ceremony to stop us early if we're ever inadvertently packaging a propolis-server with `omicron-build` and `failure-injection`. Fixes #412. --------- Co-authored-by: Greg Colombo <greg@oxidecomputer.com>
1 parent 6b5f2af commit 9ee2e1f

File tree

13 files changed

+106
-27
lines changed

13 files changed

+106
-27
lines changed

.github/buildomat/jobs/phd-build.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ rustc --version
3030
# Build the Propolis server binary with 'dev' profile to enable assertions that
3131
# should fire during tests.
3232
banner build-propolis
33-
ptime -m cargo build --verbose -p propolis-server
33+
34+
# Compile propolis-server so that it allows development features to be used even
35+
# though the `omicron-build` feature is enabled.
36+
export PHD_BUILD="true"
37+
ptime -m cargo build --verbose -p propolis-server \
38+
--features omicron-build,failure-injection
3439

3540
# The PHD runner requires unwind-on-panic to catch certain test failures, so
3641
# build it with the 'dev' profile which is so configured.

.github/buildomat/phd-run-with-args.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ if [ ! -d "$tmpdir" ]; then
3737
mkdir $tmpdir
3838
fi
3939

40+
# We'll be using the reservoir, so set it to something higher than the default
41+
# 0MiB. Most tests would only need 512MiB (the default PHD guest VM memory
42+
# size), some tests want to run multiple VMs concurrently (particularly around
43+
# migration). 4096MiB is an arbitrary number intended to support the above and
44+
# that we might want to run those tests concurrently at some point.
45+
#
46+
# Currently the lab host these tests will run on is well-known and has much
47+
# more memory than this. Hopefully we won't have Propolis CI running on a
48+
# machine with ~4GiB of memory, but this number could be tuned down if the need
49+
# arises.
50+
pfexec /usr/lib/rsrvrctl -s 4096
51+
4052
banner 'Tests'
4153

4254
runner="$phddir/phd-runner"

bin/propolis-server/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,9 @@ omicron-build = ["propolis/omicron-build"]
8383

8484
# Falcon builds require corresponding bits turned on in the dependency libs
8585
falcon = ["propolis/falcon"]
86+
87+
# Testing necessitates injecting failures which should hopefully be rare or even
88+
# never occur on real otherwise-unperturbed systems. We conditionally compile
89+
# code supporting failure injection to avoid the risk of somehow injecting
90+
# failures into a real system not under test.
91+
failure-injection = []

bin/propolis-server/src/lib/initializer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ impl MachineInitializer<'_> {
814814
Ok(())
815815
}
816816

817-
#[cfg(not(feature = "omicron-build"))]
817+
#[cfg(feature = "failure-injection")]
818818
pub fn initialize_test_devices(&mut self) {
819819
use propolis::hw::testdev::{
820820
MigrationFailureDevice, MigrationFailures,

bin/propolis-server/src/lib/migrate/preamble.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl Preamble {
5252
};
5353

5454
match comp {
55-
#[cfg(feature = "omicron-build")]
55+
#[cfg(not(feature = "failure-injection"))]
5656
ReplacementComponent::MigrationFailureInjector(_) => {
5757
return Err(MigrateError::InstanceSpecsIncompatible(
5858
format!(
@@ -62,7 +62,7 @@ impl Preamble {
6262
));
6363
}
6464

65-
#[cfg(not(feature = "omicron-build"))]
65+
#[cfg(feature = "failure-injection")]
6666
ReplacementComponent::MigrationFailureInjector(comp) => {
6767
let ComponentV0::MigrationFailureInjector(src) = to_amend
6868
else {

bin/propolis-server/src/lib/spec/api_spec_v0.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use super::{
2727
StorageDevice,
2828
};
2929

30-
#[cfg(not(feature = "omicron-build"))]
30+
#[cfg(feature = "failure-injection")]
3131
use super::MigrationFailure;
3232

3333
#[cfg(feature = "falcon")]
@@ -65,7 +65,7 @@ impl From<Spec> for InstanceSpecV0 {
6565
serial,
6666
pci_pci_bridges,
6767
pvpanic,
68-
#[cfg(not(feature = "omicron-build"))]
68+
#[cfg(feature = "failure-injection")]
6969
migration_failure,
7070
#[cfg(feature = "falcon")]
7171
softnpu,
@@ -157,7 +157,7 @@ impl From<Spec> for InstanceSpecV0 {
157157
);
158158
}
159159

160-
#[cfg(not(feature = "omicron-build"))]
160+
#[cfg(feature = "failure-injection")]
161161
if let Some(mig) = migration_failure {
162162
insert_component(
163163
&mut spec,
@@ -310,14 +310,14 @@ impl TryFrom<InstanceSpecV0> for Spec {
310310
// apply it to the builder later.
311311
boot_settings = Some((device_id, settings));
312312
}
313-
#[cfg(feature = "omicron-build")]
313+
#[cfg(not(feature = "failure-injection"))]
314314
ComponentV0::MigrationFailureInjector(_) => {
315315
return Err(ApiSpecError::FeatureCompiledOut {
316316
component: device_id,
317-
feature: "omicron-build",
317+
feature: "failure-injection",
318318
});
319319
}
320-
#[cfg(not(feature = "omicron-build"))]
320+
#[cfg(feature = "failure-injection")]
321321
ComponentV0::MigrationFailureInjector(mig) => {
322322
builder.add_migration_failure_device(MigrationFailure {
323323
id: device_id,

bin/propolis-server/src/lib/spec/builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use super::{
2626
Board, BootOrderEntry, BootSettings, Disk, Nic, QemuPvpanic, SerialPort,
2727
};
2828

29-
#[cfg(not(feature = "omicron-build"))]
29+
#[cfg(feature = "failure-injection")]
3030
use super::MigrationFailure;
3131

3232
#[cfg(feature = "falcon")]
@@ -50,7 +50,7 @@ pub(crate) enum SpecBuilderError {
5050
#[error("pvpanic device already specified")]
5151
PvpanicInUse,
5252

53-
#[cfg(not(feature = "omicron-build"))]
53+
#[cfg(feature = "failure-injection")]
5454
#[error("migration failure injection already enabled")]
5555
MigrationFailureInjectionInUse,
5656

@@ -269,7 +269,7 @@ impl SpecBuilder {
269269
Ok(self)
270270
}
271271

272-
#[cfg(not(feature = "omicron-build"))]
272+
#[cfg(feature = "failure-injection")]
273273
pub fn add_migration_failure_device(
274274
&mut self,
275275
mig: MigrationFailure,

bin/propolis-server/src/lib/spec/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use propolis_api_types::instance_spec::{
3434
};
3535
use thiserror::Error;
3636

37-
#[cfg(not(feature = "omicron-build"))]
37+
#[cfg(feature = "failure-injection")]
3838
use propolis_api_types::instance_spec::components::devices::MigrationFailureInjector;
3939

4040
#[cfg(feature = "falcon")]
@@ -73,7 +73,7 @@ pub(crate) struct Spec {
7373
pub pci_pci_bridges: BTreeMap<SpecKey, PciPciBridge>,
7474
pub pvpanic: Option<QemuPvpanic>,
7575

76-
#[cfg(not(feature = "omicron-build"))]
76+
#[cfg(feature = "failure-injection")]
7777
pub migration_failure: Option<MigrationFailure>,
7878

7979
#[cfg(feature = "falcon")]
@@ -285,7 +285,7 @@ pub struct QemuPvpanic {
285285
pub spec: QemuPvpanicDesc,
286286
}
287287

288-
#[cfg(not(feature = "omicron-build"))]
288+
#[cfg(feature = "failure-injection")]
289289
#[derive(Clone, Debug)]
290290
pub struct MigrationFailure {
291291
pub id: SpecKey,

bin/propolis-server/src/lib/vm/ensure.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,10 +564,8 @@ async fn initialize_vm_objects(
564564
))?;
565565
init.initialize_network_devices(&chipset).await?;
566566

567-
#[cfg(not(feature = "omicron-build"))]
567+
#[cfg(feature = "failure-injection")]
568568
init.initialize_test_devices();
569-
#[cfg(feature = "omicron-build")]
570-
info!(log, "`omicron-build` feature enabled, ignoring any test devices");
571569

572570
#[cfg(feature = "falcon")]
573571
{

bin/propolis-server/src/main.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,19 @@ fn main() -> anyhow::Result<()> {
278278
// Ensure proper setup of USDT probes
279279
register_probes().unwrap();
280280

281+
#[cfg(all(
282+
feature = "omicron-build",
283+
any(feature = "failure-injection", feature = "falcon")
284+
))]
285+
if option_env!("PHD_BUILD") != Some("true") {
286+
panic!(
287+
"`omicron-build` is enabled alongside development features, \
288+
this build is NOT SUITABLE for production. Set PHD_BUILD=true in \
289+
the environment and rebuild propolis-server if you really need \
290+
this to work."
291+
);
292+
}
293+
281294
// Command line arguments.
282295
let args = Args::parse();
283296

0 commit comments

Comments
 (0)