feat(#2302): thread &Ident through agent path builders
This commit is contained in:
parent
1286029947
commit
bf644cc126
23 changed files with 168 additions and 85 deletions
|
|
@ -68,11 +68,11 @@ pub async fn run(coord: &Arc<Coordinator>) -> Result<()> {
|
|||
tracing::debug!("migration: phase 1+2 (applied + proposed repos)");
|
||||
for name in &names {
|
||||
tracing::debug!(%name, "migration: applied+proposed");
|
||||
if let Err(e) = migrate_applied_repo(name).await {
|
||||
if let Err(e) = migrate_applied_repo(name.as_str()).await {
|
||||
tracing::warn!(%name, error = ?e, "migration: applied repo rewrite failed");
|
||||
}
|
||||
let proposed_dir = Coordinator::agent_proposed_dir(name);
|
||||
let proposed = lifecycle::setup_proposed(&proposed_dir, name);
|
||||
let proposed = lifecycle::setup_proposed(&proposed_dir, name.as_str());
|
||||
match tokio::time::timeout(GIT_TIMEOUT, proposed).await {
|
||||
Ok(Err(e)) => tracing::warn!(%name, error = ?e, "migration: setup_proposed failed"),
|
||||
Err(_) => {
|
||||
|
|
@ -108,8 +108,9 @@ pub async fn run(coord: &Arc<Coordinator>) -> Result<()> {
|
|||
// update activation triggers. Without this, crash_watch
|
||||
// would fire ContainerCrash for every agent here and the
|
||||
// manager would spuriously try to recover them.
|
||||
let guard = coord.transient_guard(name, crate::coordinator::TransientKind::Rebuilding);
|
||||
let result = repoint_container(name).await;
|
||||
let guard =
|
||||
coord.transient_guard(name.as_str(), crate::coordinator::TransientKind::Rebuilding);
|
||||
let result = repoint_container(name.as_str()).await;
|
||||
drop(guard);
|
||||
if let Err(e) = result {
|
||||
tracing::warn!(%name, error = ?e, "migration: container repoint failed");
|
||||
|
|
@ -140,7 +141,7 @@ pub async fn run(coord: &Arc<Coordinator>) -> Result<()> {
|
|||
/// and into the sibling harness dir. Best-effort: logs warnings but never
|
||||
/// fails. Idempotent — each file is only moved if present at the old path
|
||||
/// and absent at the new path.
|
||||
fn migrate_harness_files(name: &str) {
|
||||
fn migrate_harness_files(name: &hive_host_sock::Ident) {
|
||||
const HARNESS_FILES: &[&str] = &[
|
||||
"hyperhive-events.sqlite",
|
||||
"hyperhive-turn-stats.sqlite",
|
||||
|
|
@ -266,16 +267,17 @@ async fn rename_manager_container(coord: &Arc<Coordinator>) {
|
|||
}
|
||||
}
|
||||
|
||||
async fn enumerate_agents() -> Vec<String> {
|
||||
async fn enumerate_agents() -> Vec<hive_host_sock::Ident> {
|
||||
let containers = lifecycle::list().await.unwrap_or_default();
|
||||
containers
|
||||
.into_iter()
|
||||
.filter_map(|c| {
|
||||
if c == MANAGER_CONTAINER {
|
||||
Some(MANAGER_NAME.to_owned())
|
||||
let name = if c == MANAGER_CONTAINER {
|
||||
MANAGER_NAME
|
||||
} else {
|
||||
c.strip_prefix(AGENT_PREFIX).map(str::to_owned)
|
||||
}
|
||||
c.strip_prefix(AGENT_PREFIX)?
|
||||
};
|
||||
hive_host_sock::Ident::parse(name).ok()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
@ -351,8 +353,8 @@ async fn repoint_container(name: &str) -> Result<()> {
|
|||
/// Idempotent — skips when entry already present. Prevents a silent tool
|
||||
/// downgrade when upgrading from a build that relied on the manager-flavor
|
||||
/// fallback in `effective_tool_groups()`.
|
||||
fn backfill_manager_tool_groups(names: &[String]) {
|
||||
if !names.iter().any(|n| n == MANAGER_NAME) {
|
||||
fn backfill_manager_tool_groups(names: &[hive_host_sock::Ident]) {
|
||||
if !names.iter().any(|n| n.as_str() == MANAGER_NAME) {
|
||||
return; // ruth not deployed — nothing to backfill
|
||||
}
|
||||
let existing = tool_groups::groups_for(MANAGER_NAME);
|
||||
|
|
|
|||
Loading…
Reference in a new issue