Complete customer transfers on first authenticated inventory
Rust development slice / linux (push) Failing after 8s

This commit is contained in:
2026-11-18 22:57:05 +01:00
parent 65d84a19c0
commit 480e3749a6
13 changed files with 234 additions and 76 deletions
+11 -1
View File
@@ -105,7 +105,7 @@ pub async fn ingest(
);
let mut tx = rmm_persistence::tenant_tx(&state.pool, tenant).await?;
control_lock(&mut tx, tenant, agent).await?;
let row=sqlx::query("SELECT revoked_at,connection_generation,transport,connection_boot_id,last_sequence,capabilities FROM agent_installations WHERE agent_id=$1 FOR UPDATE").bind(agent).fetch_one(&mut *tx).await?;
let row=sqlx::query("SELECT revoked_at,connection_generation,transport,connection_boot_id,last_sequence,capabilities,customer_transfer_pending FROM agent_installations WHERE agent_id=$1 FOR UPDATE").bind(agent).fetch_one(&mut *tx).await?;
let active = row.get::<Option<DateTime<Utc>>, _>("revoked_at").is_none()
&& row.get::<i64, _>("connection_generation") == i64::try_from(e.connection_generation)?
&& row.get::<String, _>("transport") == transport;
@@ -196,6 +196,16 @@ pub async fn ingest(
}
_ => anyhow::bail!("unsupported capability"),
}
if row.get::<bool, _>("customer_transfer_pending")
&& (matches!(&e.payload, Some(Payload::Heartbeat(_)))
|| matches!(&e.payload, Some(Payload::InventorySnapshot(s)) if s.scope != "agent.update"))
{
sqlx::query("SELECT finish_device_customer_transfer($1,$2)")
.bind(tenant)
.bind(agent)
.execute(&mut *tx)
.await?;
}
tx.commit().await?;
Ok(reply(
e,