Add gated agent update planning, preserved handoff and Linux worker ports
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-14 21:48:21 +01:00
parent dc9cb1b096
commit 1e89c4577f
82 changed files with 25052 additions and 69 deletions
+47 -1
View File
@@ -184,6 +184,15 @@ impl<C: reconcile::SyncClock> Agent<C> {
.as_mut()
.context("SYNC_REQUIRED")?
.confirm_helper(&snapshot)?;
} else if snapshot
.attempts
.iter()
.any(|a| !a.update_handoff_bytes.is_empty())
{
self.sync
.as_mut()
.context("SYNC_REQUIRED")?
.confirm_update_helper(&snapshot)?;
}
}
if self.ready(generation, false) {
@@ -389,7 +398,11 @@ impl<C: reconcile::SyncClock> Agent<C> {
})
}
fn capabilities(&self) -> Vec<String> {
let mut capabilities = vec!["linux.base/1".into(), "heartbeat/1".into()];
let mut capabilities = vec![
"linux.base/1".into(),
"heartbeat/1".into(),
"agent.update/1".into(),
];
if self.binding.is_some() {
capabilities.push("rmm.sync.v1".into());
}
@@ -435,6 +448,33 @@ impl<C: reconcile::SyncClock> Agent<C> {
let _ = sender.blocking_send(result);
});
}
fn queue_update_observation(&mut self, generation: u64) -> Result<()> {
if !storage::passive_collection_ready(&self.db)? {
return Ok(());
}
// Until the separately qualified protected updater/helper observer is
// provisioned, report its real absence; never infer apply readiness from
// this schema support or the agent's own code/build version.
let observation = rmm_domain::agent_update::AgentUpdateObservation::not_configured(
rmm_domain::agent_update::Platform::LinuxX64,
Utc::now(),
);
let data = serde_json::to_vec(&serde_json::json!({"agent_update":observation}))?;
let envelope = self.envelope(
generation,
Payload::InventorySnapshot(rmm_protocol::InventorySnapshot {
snapshot_id: Uuid::new_v4().to_string(),
scope: "agent.update".into(),
schema_version: 1,
chunk_index: 0,
chunk_count: 1,
sha256: Sha256::digest(&data).to_vec(),
data,
completeness: "partial".into(),
}),
)?;
jobs::event(&self.db, &envelope)
}
fn inventory_envelope(
&mut self,
generation: u64,
@@ -507,6 +547,7 @@ impl<C: reconcile::SyncClock> Agent<C> {
storage::clear_pending(&self.db)?;
}
self.queue_inventory();
self.queue_update_observation(generation)?;
self.replay(&ws, generation).await?;
let mut needs_sync = false;
if self.sync.is_some()
@@ -518,6 +559,7 @@ impl<C: reconcile::SyncClock> Agent<C> {
}
eprintln!("authenticated channel established; inventory queued for durable acknowledgment");
let mut inventory_at = Instant::now();
let mut update_at = Instant::now();
let mut heartbeat_at = Instant::now();
let mut heartbeat_after = Duration::from_millis(rand::random_range(27_000..33_000));
let mut tick = tokio::time::interval(Duration::from_secs(5));
@@ -648,6 +690,10 @@ impl<C: reconcile::SyncClock> Agent<C> {
// Planning pins must be refreshed before the 90-second stored-data
// planning limit. One inflight blocking collector bounds pressure;
// heartbeats never perform this metadata work.
if update_at.elapsed() >= Duration::from_secs(60) {
self.queue_update_observation(generation)?;
update_at = Instant::now();
}
if inventory_at.elapsed() >= Duration::from_secs(60) {
self.queue_inventory();
inventory_at = Instant::now();