MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / replica_id

Function replica_id

crates/openshell-server/src/compute/lease.rs:246–250  ·  view source on GitHub ↗

Derive a stable replica identity for lease ownership. Kubernetes sets `HOSTNAME` to the pod name, Docker sets it to the container ID, and systemd units inherit the machine hostname. `OPENSHELL_REPLICA_ID` allows explicit override. The UUID fallback handles edge cases where neither env var is set.

()

Source from the content-addressed store, hash-verified

244/// `OPENSHELL_REPLICA_ID` allows explicit override. The UUID fallback
245/// handles edge cases where neither env var is set.
246pub fn replica_id() -> String {
247 std::env::var("OPENSHELL_REPLICA_ID")
248 .or_else(|_| std::env::var("HOSTNAME"))
249 .unwrap_or_else(|_| uuid::Uuid::new_v4().to_string())
250}
251
252#[cfg(test)]
253mod tests {

Callers 2

from_driverMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected