feat: qualify bound configure-only recovery runtime on cloud VM
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-13 18:07:46 +01:00
parent b24314da9e
commit 2230235dfb
21 changed files with 1749 additions and 80 deletions
+86 -8
View File
@@ -10,6 +10,8 @@ pub const UPDATE_SHA: &str = "ef67c9fe0ba1443fcfe465768e1204763063c369a2a1da04af
#[serde(deny_unknown_fields)]
pub struct ResolvedAptTransaction {
pub schema_version: u32,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub operation: Option<AptTransactionOperation>,
pub recipe_id: String,
pub recipe_version: String,
pub platform: String,
@@ -33,6 +35,29 @@ pub struct PackageArchive {
}
pub type AptExpectation = ResolvedAptTransaction;
pub type AptExpectedPackage = PackageArchive;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, schemars::JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum AptTransactionOperation {
ConfigureOnly,
}
/// One new explicitly approved configure-only job after a proven partial
/// fixture effect. This does not retry the old consumed attempt.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, schemars::JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct AptNativeRecovery {
pub schema_version: u32,
pub previous_grant_id: uuid::Uuid,
pub previous_attempt_id: uuid::Uuid,
pub partial_proof_sha256: String,
}
impl AptNativeRecovery {
pub fn validate(&self) -> bool {
self.schema_version == 1
&& !self.previous_grant_id.is_nil()
&& !self.previous_attempt_id.is_nil()
&& digest(&self.partial_proof_sha256)
}
}
/// One explicitly approved recovery of a fixture acceptance that failed before
/// the trusted pre-dpkg hook. The original create-once marker remains intact.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, schemars::JsonSchema)]
@@ -69,11 +94,12 @@ pub struct AptExecutionManifest {
pub test_result_id: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub native_retry: Option<AptNativeRetry>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub native_recovery: Option<AptNativeRecovery>,
}
impl ResolvedAptTransaction {
pub fn validate_fixture(&self) -> bool {
if self.schema_version != 1
|| self.recipe_version != "1"
if self.recipe_version != "1"
|| self.platform != "ubuntu-24.04-amd64"
|| self.resolver_config_version != "rmm-apt-local-v1"
|| !self.no_reboot
@@ -84,9 +110,16 @@ impl ResolvedAptTransaction {
return false;
}
let package = &self.packages[0];
let (old, new, sha) = match self.recipe_id.as_str() {
INSTALL_RECIPE => (None, "1.0", INSTALL_SHA),
UPDATE_RECIPE => (Some("1.0"), "1.1", UPDATE_SHA),
let (old, new, sha) = match (
self.schema_version,
&self.operation,
self.recipe_id.as_str(),
) {
(1, None, INSTALL_RECIPE) => (None, "1.0", INSTALL_SHA),
(1, None, UPDATE_RECIPE) => (Some("1.0"), "1.1", UPDATE_SHA),
(2, Some(AptTransactionOperation::ConfigureOnly), INSTALL_RECIPE) => {
(Some("1.0"), "1.0", INSTALL_SHA)
}
_ => return false,
};
package.name == "rmm-mvp-test"
@@ -106,9 +139,23 @@ impl ResolvedAptTransaction {
impl AptExecutionManifest {
pub fn validate(&self) -> bool {
self.kind == "rmm.apt.helper-action"
&& match (&self.native_retry, self.schema_version) {
(None, 2) => true,
(Some(retry), 3) => self.action == "apt-native-acceptance" && retry.validate(),
&& match (
&self.native_retry,
&self.native_recovery,
self.schema_version,
) {
(None, None, 2) => self.resolved_apt_transaction.operation.is_none(),
(Some(retry), None, 3) => {
self.action == "apt-native-acceptance"
&& retry.validate()
&& self.resolved_apt_transaction.operation.is_none()
}
(None, Some(recovery), 4) => {
self.action == "apt-native-acceptance"
&& recovery.validate()
&& self.resolved_apt_transaction.operation
== Some(AptTransactionOperation::ConfigureOnly)
}
_ => false,
}
&& matches!(
@@ -197,6 +244,7 @@ impl PinnedAptTransaction {
let expectation: AptExpectation = serde_json::from_slice(&self.expectation_bytes)
.map_err(|_| "INVALID_APT_EXPECTATION")?;
if expectation.schema_version != 1
|| expectation.operation.is_some()
|| expectation.platform != "ubuntu-24.04-amd64"
|| !expectation.no_reboot
|| !label(&expectation.recipe_id)
@@ -312,6 +360,7 @@ mod tests {
fn helper_schema_two_roundtrip_and_strict_action_binding() {
let t = ResolvedAptTransaction {
schema_version: 1,
operation: None,
recipe_id: INSTALL_RECIPE.into(),
recipe_version: "1".into(),
platform: "ubuntu-24.04-amd64".into(),
@@ -345,8 +394,36 @@ mod tests {
runtime_sha256: hash(b"runtime"),
test_result_id: "fixture-test-1".into(),
native_retry: None,
native_recovery: None,
};
assert!(m.validate());
let mut recovery = m.clone();
recovery.schema_version = 4;
recovery.native_recovery = Some(AptNativeRecovery {
schema_version: 1,
previous_grant_id: Uuid::new_v4(),
previous_attempt_id: Uuid::new_v4(),
partial_proof_sha256: hash(b"closed partial"),
});
recovery.resolved_apt_transaction.schema_version = 2;
recovery.resolved_apt_transaction.operation = Some(AptTransactionOperation::ConfigureOnly);
recovery.resolved_apt_transaction.packages[0].old_version = Some("1.0".into());
recovery.transaction_bytes =
crate::jobs::encode(&recovery.resolved_apt_transaction).unwrap();
recovery.transaction_sha256 = hash(&recovery.transaction_bytes);
assert!(recovery.validate());
let mut disguised = recovery.clone();
disguised.schema_version = 2;
assert!(!disguised.validate());
disguised = recovery.clone();
disguised.action = "apt-execute".into();
assert!(!disguised.validate());
disguised = recovery.clone();
disguised.native_recovery = None;
assert!(!disguised.validate());
let mut equal_normal = m.resolved_apt_transaction.clone();
equal_normal.packages[0].old_version = Some("1.0".into());
assert!(!equal_normal.validate_fixture());
assert!(
!serde_json::to_value(&m)
.unwrap()
@@ -408,6 +485,7 @@ mod tests {
};
let expectation = AptExpectation {
schema_version: 1,
operation: None,
recipe_id: "fixture".into(),
recipe_version: "1".into(),
platform: "ubuntu-24.04-amd64".into(),