Skip to content

Commit 351b657

Browse files
committed
fix: use actual hostname as fallback for broker URL
When VALIDATOR_NAME and VALIDATOR_CONTAINER_NAME are not set, fallback to the actual system hostname instead of 'platform-server'. This fixes DNS resolution errors for validators running in containers without explicit name configuration.
1 parent 9387864 commit 351b657

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/challenge-orchestrator/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ tracing = { workspace = true }
3636
chrono = { workspace = true }
3737
parking_lot = { workspace = true }
3838
uuid = { workspace = true }
39+
hostname = "0.4"
3940

4041
[dev-dependencies]
4142
tempfile = { workspace = true }

crates/challenge-orchestrator/src/docker.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,18 @@ impl DockerClient {
579579
env.push(format!("DATABASE_URL={}/{}", db_url, challenge_db_name));
580580
}
581581
}
582-
// Local hostname for broker (always local)
582+
// Local hostname for broker (always local to validator container)
583+
// Priority: VALIDATOR_NAME -> VALIDATOR_CONTAINER_NAME -> system hostname
583584
let platform_host = std::env::var("VALIDATOR_NAME")
584585
.map(|name| format!("platform-{}", name))
585586
.unwrap_or_else(|_| {
586-
std::env::var("VALIDATOR_CONTAINER_NAME")
587-
.unwrap_or_else(|_| "platform-server".to_string())
587+
std::env::var("VALIDATOR_CONTAINER_NAME").unwrap_or_else(|_| {
588+
// Fallback to actual hostname of current container
589+
hostname::get()
590+
.ok()
591+
.and_then(|h| h.into_string().ok())
592+
.unwrap_or_else(|| "localhost".to_string())
593+
})
588594
});
589595

590596
// Pass Platform URL for metagraph verification and API calls

0 commit comments

Comments
 (0)