Bind updater reader registry and prove process census fixtures on cloud Linux
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -4,12 +4,13 @@
|
||||
use crate::{
|
||||
agent_startup::BoundAgentLock,
|
||||
bridge::{BridgeContext, FullBridge, Generation},
|
||||
bundle,
|
||||
bundle, census,
|
||||
clock::NativeClock,
|
||||
fence::LedgerFence,
|
||||
ledger::{OwnedInputs, OwnedLedger},
|
||||
original::Original,
|
||||
participants::{StableParticipant, verify_original_helper},
|
||||
reader_registry::QualifiedRegistry,
|
||||
retained::RetainedSet,
|
||||
returned,
|
||||
trust::TrustState,
|
||||
@@ -21,7 +22,7 @@ use rmm_agent_core::{
|
||||
update_handoff::{NativeControlOperation, NativeEffect, NativeEffectClaim, NativeService},
|
||||
};
|
||||
use rmm_domain::{
|
||||
agent_update::{ParticipantIdentity, ParticipantRole, UpdateInflightProof},
|
||||
agent_update::{ParticipantIdentity, ParticipantRole},
|
||||
agent_update_provisioning::{HealthKeyPin, InstalledReleaseRecord, LocalUpdatePolicy},
|
||||
jobs::hash,
|
||||
};
|
||||
@@ -75,6 +76,7 @@ impl Protected {
|
||||
pub struct Runtime {
|
||||
binding: Binding,
|
||||
policy: LocalUpdatePolicy,
|
||||
registry: QualifiedRegistry,
|
||||
policy_sha256: String,
|
||||
installed: InstalledReleaseRecord,
|
||||
installed_sha256: String,
|
||||
@@ -91,12 +93,8 @@ pub struct Runtime {
|
||||
head: Option<String>,
|
||||
}
|
||||
struct Queued {
|
||||
agent_startup: BoundAgentLock,
|
||||
original: Original,
|
||||
witnesses: bundle::Loaded,
|
||||
trust: TrustState,
|
||||
header: bundle::Header,
|
||||
budget: Budget,
|
||||
proof: UpdateInflightProof,
|
||||
}
|
||||
impl Runtime {
|
||||
pub fn new(binding: Binding) -> Result<Self> {
|
||||
@@ -117,6 +115,7 @@ impl Runtime {
|
||||
let installed = InstalledReleaseRecord::from_bytes(&raw).map_err(anyhow::Error::msg)?;
|
||||
let installed_sha256 = hash(&raw);
|
||||
let old_policies = service_policies(&policy, &installed, None)?;
|
||||
let registry = QualifiedRegistry::load(&policy)?;
|
||||
let (health_file, raw) = Protected::read(&policy.health_pin_path, 4096)?;
|
||||
let health: HealthKeyPin = serde_json::from_slice(&raw)?;
|
||||
let health_key = health.public_key().map_err(anyhow::Error::msg)?;
|
||||
@@ -131,6 +130,7 @@ impl Runtime {
|
||||
Ok(Self {
|
||||
binding,
|
||||
policy,
|
||||
registry,
|
||||
policy_sha256,
|
||||
installed,
|
||||
installed_sha256,
|
||||
@@ -150,7 +150,7 @@ impl Runtime {
|
||||
/// A lost activation reply disables this live runtime before any stop.
|
||||
/// Drive is deliberately private: it cannot run inside Engine::handle.
|
||||
pub fn serve_one(&mut self, listener: &ipc::Listener) -> Result<()> {
|
||||
self.require_reader_registry_and_census()?;
|
||||
self.registry.verify_protected()?;
|
||||
ensure!(!self.failed && !self.terminal, "UPDATE_ENGINE_CLOSED");
|
||||
let services = Systemd::new(self.old_policies.clone())?;
|
||||
let budget = observation_budget()?;
|
||||
@@ -173,12 +173,6 @@ impl Runtime {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn require_reader_registry_and_census(&self) -> Result<()> {
|
||||
// This is an explicit source-checkpoint barrier, not a caller boolean
|
||||
// or a known-unit-list substitute. Replace only with the real protected
|
||||
// bootstrap registry + complete live FD/maps census and both locks.
|
||||
anyhow::bail!("UPDATE_READER_CENSUS_NOT_CONFIGURED")
|
||||
}
|
||||
fn enqueue(
|
||||
&mut self,
|
||||
peer: &ParticipantIdentity,
|
||||
@@ -216,17 +210,33 @@ impl Runtime {
|
||||
verify_original_helper(&services, &header.delegation, &budget)?;
|
||||
self.updater
|
||||
.verify_delegation(&header.delegation, &budget)?;
|
||||
let mut bridge = FullBridge::original(BridgeContext {
|
||||
handoff: &header.handoff,
|
||||
delegation: &header.delegation,
|
||||
services: &services,
|
||||
updater: &self.updater,
|
||||
clock: &self.clock,
|
||||
budget: &budget,
|
||||
health_public_key: self.health_key,
|
||||
generation: Generation::Original,
|
||||
})?;
|
||||
let reply = bridge.call(NativeControlOperation::ReadOriginal)?;
|
||||
// The original Full is still synchronously waiting for this reply.
|
||||
// Do not recursively query its socket or ledger in the Activate handler.
|
||||
self.queued = Some(Queued { header, budget });
|
||||
Ok(())
|
||||
}
|
||||
fn drive(&mut self, queued: Queued) -> Result<()> {
|
||||
let Queued { header, budget } = queued;
|
||||
for file in &self.protected {
|
||||
file.verify()?;
|
||||
}
|
||||
let services = Systemd::new(self.old_policies.clone())?;
|
||||
verify_original_helper(&services, &header.delegation, &budget)?;
|
||||
self.updater
|
||||
.verify_delegation(&header.delegation, &budget)?;
|
||||
let reply = {
|
||||
let mut bridge = FullBridge::original(BridgeContext {
|
||||
handoff: &header.handoff,
|
||||
delegation: &header.delegation,
|
||||
services: &services,
|
||||
updater: &self.updater,
|
||||
clock: &self.clock,
|
||||
budget: &budget,
|
||||
health_public_key: self.health_key,
|
||||
generation: Generation::Original,
|
||||
})?;
|
||||
bridge.call(NativeControlOperation::ReadOriginal)?
|
||||
};
|
||||
let proof = reply.proof.context("UPDATE_ENGINE_ORIGINAL_PROOF")?;
|
||||
let original = Original::verify(
|
||||
&self.binding,
|
||||
@@ -256,32 +266,19 @@ impl Runtime {
|
||||
witnesses.retained.verify()?;
|
||||
let agent_startup = BoundAgentLock::bind(&witnesses.retained)?;
|
||||
self.head = Some(proof.head_sha256.clone());
|
||||
self.queued = Some(Queued {
|
||||
agent_startup,
|
||||
original,
|
||||
witnesses,
|
||||
trust,
|
||||
budget,
|
||||
proof,
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
fn drive(&mut self, queued: Queued) -> Result<()> {
|
||||
let Queued {
|
||||
agent_startup,
|
||||
original,
|
||||
witnesses,
|
||||
trust,
|
||||
budget,
|
||||
proof,
|
||||
} = queued;
|
||||
original.check_current(&self.binding, &self.clock, &budget)?;
|
||||
trust.recheck(&original, &self.clock)?;
|
||||
let services = Systemd::new(self.old_policies.clone())?;
|
||||
let old = [Service::Agent, Service::General, Service::Full]
|
||||
self.registry.verify_admission(&self.policy, &budget)?;
|
||||
let held = [Service::Agent, Service::General, Service::Full]
|
||||
.into_iter()
|
||||
.map(|s| services.observe(s, &budget).map(|h| h.proof().clone()))
|
||||
.map(|s| services.observe(s, &budget))
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
let known = vec![&held[0], &held[1], &held[2], self.updater.held_service()];
|
||||
let old = held.iter().map(|h| h.proof().clone()).collect::<Vec<_>>();
|
||||
let targets =
|
||||
census::Targets::bind(&witnesses.retained, &witnesses.ledger, &agent_startup)?;
|
||||
let admission =
|
||||
census::scan_admission(&targets, &known, self.registry.host_context(), &budget)?;
|
||||
let mut bridge = FullBridge::new(
|
||||
BridgeContext {
|
||||
handoff: original.handoff(),
|
||||
@@ -321,6 +318,10 @@ impl Runtime {
|
||||
updater: &self.updater,
|
||||
trust: &trust,
|
||||
retained: &witnesses.retained,
|
||||
registry: &self.registry,
|
||||
targets: &targets,
|
||||
admission: &admission,
|
||||
known: &known,
|
||||
claims,
|
||||
old,
|
||||
next: 0,
|
||||
@@ -331,8 +332,30 @@ impl Runtime {
|
||||
let claims = stop_fence.finish()?;
|
||||
let agent_startup = agent_startup.acquire(&stopped, &budget)?;
|
||||
let os = LedgerGuard::acquire(&stopped, &witnesses.ledger, &budget)?;
|
||||
self.registry.verify_stopped(&self.policy, &budget)?;
|
||||
let readers = census::scan_stopped(
|
||||
&targets,
|
||||
&admission,
|
||||
&os,
|
||||
&agent_startup,
|
||||
&stopped,
|
||||
self.updater.held_service(),
|
||||
&budget,
|
||||
)?;
|
||||
let readers = readers.bind(
|
||||
census::ClosureInputs {
|
||||
targets: &targets,
|
||||
root: &os,
|
||||
agent: &agent_startup,
|
||||
stopped: &stopped,
|
||||
updater: self.updater.held_service(),
|
||||
registry: &self.registry,
|
||||
},
|
||||
&budget,
|
||||
)?;
|
||||
let mut ledger = OwnedLedger::open(OwnedInputs {
|
||||
os: &os,
|
||||
readers: &readers,
|
||||
original: &original,
|
||||
binding: &self.binding,
|
||||
clock: &self.clock,
|
||||
@@ -391,6 +414,9 @@ impl Runtime {
|
||||
return Err(error);
|
||||
}
|
||||
let prepared = ledger.prepare_return_and_close()?;
|
||||
// The original DB is actually closed. End the continuous census/lock
|
||||
// borrow before the same concrete guard can be consumed by Return.
|
||||
drop(readers);
|
||||
let reservation = prepared.bind(returned::Inputs {
|
||||
original: &original,
|
||||
binding: &self.binding,
|
||||
@@ -490,6 +516,10 @@ struct StopFence<'a> {
|
||||
updater: &'a StableParticipant,
|
||||
trust: &'a TrustState,
|
||||
retained: &'a RetainedSet,
|
||||
registry: &'a QualifiedRegistry,
|
||||
targets: &'a census::Targets,
|
||||
admission: &'a census::Admission,
|
||||
known: &'a [&'a rmm_updater_linux::services::HeldService],
|
||||
claims: Vec<NativeEffectClaim>,
|
||||
old: Vec<ServiceProof>,
|
||||
next: usize,
|
||||
@@ -503,6 +533,7 @@ impl StopFence<'_> {
|
||||
self.updater
|
||||
.verify_delegation(self.original.delegation(), self.budget)?;
|
||||
self.trust.recheck(self.original, self.clock)?;
|
||||
self.registry.verify_protected()?;
|
||||
self.retained.verify()
|
||||
}
|
||||
fn finish(self) -> Result<Vec<NativeEffectClaim>> {
|
||||
@@ -522,6 +553,10 @@ impl DurableEffectFence for StopFence<'_> {
|
||||
);
|
||||
self.poisoned = true;
|
||||
self.current()?;
|
||||
if self.next == 0 {
|
||||
self.admission
|
||||
.verify_fresh(self.targets, self.known, self.budget)?;
|
||||
}
|
||||
let service = [Service::Agent, Service::General, Service::Full][self.next];
|
||||
let native = [
|
||||
NativeService::Agent,
|
||||
|
||||
Reference in New Issue
Block a user