Add gated agent update planning, preserved handoff and Linux worker ports
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -613,6 +613,7 @@ pub fn map_snapshot(s: &Snapshot) -> HelperSnapshot {
|
||||
.attempts
|
||||
.iter()
|
||||
.map(|a| SyncAttempt {
|
||||
update_handoff_bytes: a.update_handoff_bytes.clone(),
|
||||
job_id: a.job_id.to_string(),
|
||||
attempt_id: a.attempt_id.to_string(),
|
||||
job_payload_hash: a.job_payload_hash.clone(),
|
||||
@@ -874,6 +875,7 @@ mod tests {
|
||||
);
|
||||
// Pure mirror-binding negatives, not a signature/OS authentication proof.
|
||||
let permit = rmm_domain::jobs::ExecutionPermitPayload {
|
||||
agent_update_plan_id: None,
|
||||
domain: "rmm.execution-permit".into(),
|
||||
schema_version: 1,
|
||||
grant_id: id,
|
||||
@@ -900,6 +902,7 @@ mod tests {
|
||||
.unwrap();
|
||||
let bytes = rmm_domain::reconciliation::canonical_outcome_bytes(&canonical).unwrap();
|
||||
let row = rmm_agent_core::helper_reconcile::LocalAttempt {
|
||||
update_handoff_bytes: Vec::new(),
|
||||
job_id: id,
|
||||
attempt_id: id,
|
||||
job_payload_hash: permit.job_payload_hash.clone(),
|
||||
|
||||
@@ -489,12 +489,17 @@ impl Agent {
|
||||
ensure!(expected == generation, "HELPER_CHANNEL_CHANGED");
|
||||
let snapshot = task.await??;
|
||||
self.helper_anchor = snapshot.no_start_anchor;
|
||||
self.sync
|
||||
.as_mut()
|
||||
.context("SYNC_NOT_CONFIGURED")?
|
||||
.confirm_helper(&rmm_agent_windows::helper_runtime::map_snapshot(
|
||||
&snapshot.raw,
|
||||
))?;
|
||||
let mapped = rmm_agent_windows::helper_runtime::map_snapshot(&snapshot.raw);
|
||||
let sync = self.sync.as_mut().context("SYNC_NOT_CONFIGURED")?;
|
||||
if mapped
|
||||
.attempts
|
||||
.iter()
|
||||
.any(|a| !a.update_handoff_bytes.is_empty())
|
||||
{
|
||||
sync.confirm_update_helper(&mapped)?;
|
||||
} else {
|
||||
sync.confirm_helper(&mapped)?;
|
||||
}
|
||||
self.open_fence(generation)?;
|
||||
}
|
||||
}
|
||||
@@ -602,6 +607,7 @@ impl Agent {
|
||||
}
|
||||
fn capabilities(&self) -> Vec<String> {
|
||||
let mut caps: Vec<String> = CAPABILITIES.iter().map(|c| c.to_string()).collect();
|
||||
caps.push("agent.update/1".into());
|
||||
if self.config.enable_jobs
|
||||
&& self.binding.is_some()
|
||||
&& native::require_local_service().is_ok()
|
||||
@@ -1243,6 +1249,36 @@ impl Agent {
|
||||
self.journal.save(&envelope)
|
||||
}
|
||||
}
|
||||
fn queue_update_observation(&mut self, generation: u64) -> Result<()> {
|
||||
if self.journal.count()? > 0 || !jobs::events(self.journal.connection())?.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
// Schema support is passive only; no qualified updater/helper observer
|
||||
// is configured by this source checkpoint, so apply remains closed.
|
||||
let observation = rmm_domain::agent_update::AgentUpdateObservation::not_configured(
|
||||
rmm_domain::agent_update::Platform::WindowsX64,
|
||||
Utc::now(),
|
||||
);
|
||||
let data = serde_json::to_vec(&serde_json::json!({"agent_update":observation}))?;
|
||||
let envelope = self.envelope(
|
||||
generation,
|
||||
Payload::InventorySnapshot(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(),
|
||||
}),
|
||||
)?;
|
||||
if self.binding.is_some() {
|
||||
jobs::event(self.journal.connection(), &envelope)
|
||||
} else {
|
||||
self.journal.save(&envelope)
|
||||
}
|
||||
}
|
||||
async fn session(&mut self, stop: &AtomicBool) -> Result<()> {
|
||||
self.close_gate();
|
||||
let result = self.session_inner(stop).await;
|
||||
@@ -1296,6 +1332,7 @@ impl Agent {
|
||||
"SERVER_LIMITS"
|
||||
);
|
||||
self.queue_inventory(generation)?;
|
||||
self.queue_update_observation(generation)?;
|
||||
self.replay(&channel, generation).await?;
|
||||
let mut needs_sync = self.sync.is_some();
|
||||
if self.sync.is_some() && self.running.is_none() {
|
||||
@@ -1309,6 +1346,7 @@ impl Agent {
|
||||
let mut capabilities_at = Instant::now();
|
||||
let mut replay = Instant::now() - Duration::from_secs(10);
|
||||
let mut inventory = Instant::now();
|
||||
let mut update_at = Instant::now();
|
||||
let mut heartbeat = Instant::now() - Duration::from_secs(60);
|
||||
let mut heartbeat_after = Duration::from_secs(30);
|
||||
let mut tick = tokio::time::interval(Duration::from_secs(1));
|
||||
@@ -1422,6 +1460,10 @@ impl Agent {
|
||||
self.queue_inventory(generation)?;
|
||||
inventory = Instant::now();
|
||||
}
|
||||
if !stop.load(Ordering::SeqCst) && update_at.elapsed() >= Duration::from_secs(60) {
|
||||
self.queue_update_observation(generation)?;
|
||||
update_at = Instant::now();
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user