hive-agent: the swarm queue connection is required; retry, then exit
An agent's harness connects to the swarm queue with the agent's own credential or not at all. The first connect retries after 5s, doubling (7 attempts, about five minutes), with a warning per failed attempt; when every attempt fails the harness logs an error and exits 1. Missing coordinates (HIVE_AGENT_NATS_URL, or the secret store's BAO_ADDR / HIVE_AGENT_NAME / certificate) fail the boot outright. Previously the first connect's outcome was memoized for the life of the process: a store 403 or queue refusal at boot left the agent on the hive's shared client, or disconnected, until someone restarted it, and an agent with no queue coordinates ran on without one. Both paths are gone, with the hive-scoped subjects that only the shared client used. The harness unit now restarts after 30s instead of 2s, so a swarm-wide outage doesn't restart every agent every 2s, and has no start limit, so it keeps coming back however long the outage lasts. The hive's shared client credential is still imported into the harness unit for swarm-logs; the two HIVE_AGENT_OIDC_*_FILE variables that pointed the harness at it are dropped, as is the unset HIVE_AGENT_OIDC_CA_FILE override. With the fallback gone, the pieces #4944 added only for it go too: swarm_input's skip-on-shared-client branch and swarm-queue-client's connect_with_inbox_prefix. swarm-nats-auth's grant for the hive's shared agent client is unchanged. Closes #4909
This commit is contained in:
parent
147b9e0a23
commit
235bc481b3
16 changed files with 392 additions and 964 deletions
|
|
@ -771,22 +771,6 @@ pub fn install_crypto_provider() {
|
|||
/// token expires, the controller keeps serving, its status data quietly stops
|
||||
/// updating, and nothing says so until someone reads a dashboard.
|
||||
pub async fn connect(cfg: QueueConfig) -> Result<async_nats::Client, Error> {
|
||||
connect_inner(cfg, None).await
|
||||
}
|
||||
|
||||
/// [`connect`], with reply inboxes under `inbox_prefix`. For a client whose
|
||||
/// grant limits subscribe to that prefix, such as [`client_inbox_prefix`].
|
||||
pub async fn connect_with_inbox_prefix(
|
||||
cfg: QueueConfig,
|
||||
inbox_prefix: String,
|
||||
) -> Result<async_nats::Client, Error> {
|
||||
connect_inner(cfg, Some(inbox_prefix)).await
|
||||
}
|
||||
|
||||
async fn connect_inner(
|
||||
cfg: QueueConfig,
|
||||
inbox_prefix: Option<String>,
|
||||
) -> Result<async_nats::Client, Error> {
|
||||
install_crypto_provider();
|
||||
// Trusts `cfg.ca_file` when set (the swarm's own CA, when the token
|
||||
// endpoint is signed by it) — see `build_http_client`. A timeout too,
|
||||
|
|
@ -871,9 +855,6 @@ async fn connect_inner(
|
|||
if let Some(path) = ca_file {
|
||||
options = options.add_root_certificates(path);
|
||||
}
|
||||
if let Some(prefix) = inbox_prefix {
|
||||
options = options.custom_inbox_prefix(prefix);
|
||||
}
|
||||
|
||||
let client = options
|
||||
.connect(&url)
|
||||
|
|
@ -896,7 +877,7 @@ async fn connect_inner(
|
|||
///
|
||||
/// Unlike [`connect`], the first attempt must succeed: a refused or failed
|
||||
/// connect is returned rather than retried in the background, so the caller
|
||||
/// can fall back to another credential. `ca_file` is the queue's trust anchor,
|
||||
/// sees it and decides how to retry. `ca_file` is the queue's trust anchor,
|
||||
/// as [`QueueConfig::ca_file`].
|
||||
pub async fn connect_with_token<F, Fut>(
|
||||
url: &str,
|
||||
|
|
|
|||
Loading…
Reference in a new issue