From 5e5448bdd899ba9ba263200616a348acda5eb0ed Mon Sep 17 00:00:00 2001 From: jbordalo Date: Wed, 11 Feb 2026 13:59:59 +0000 Subject: Add support for differing username between cluster and local machine --- README.md | 2 ++ src/context.rs | 9 +++++++++ src/main.rs | 14 ++++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 49c12bc..fbe1bd4 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ export FRONTEND_HOSTNAME="" # tell oar-p2p to auto detect that job and use it so you dont have to # specify the job id. # export OAR_P2P_INFER_JOB_ID=true +# optionally, you can pass the cluster username if it differs from the local one +# export CLUSTER_USERNAME="" ``` you can now use a tool like [direnv](https://direnv.net) or just `source` the file with those variables. diff --git a/src/context.rs b/src/context.rs index f67c302..4c1b639 100644 --- a/src/context.rs +++ b/src/context.rs @@ -15,6 +15,7 @@ pub struct Context { job_id: Option, infer_job_id: bool, frontend_hostname: Option, + cluster_username: Option } impl Context { @@ -22,12 +23,14 @@ impl Context { job_id: Option, infer_job_id: bool, frontend_hostname: Option, + cluster_username: Option ) -> Result { Ok(Self { node: get_execution_node().await?, job_id, infer_job_id, frontend_hostname, + cluster_username }) } @@ -57,6 +60,12 @@ impl Context { .as_deref() .ok_or_else(|| eyre::eyre!("missing frontend hostname")) } + + pub fn cluster_username(&self) -> Result<&str> { + self.cluster_username + .as_deref() + .ok_or_else(|| eyre::eyre!("missing cluster username")) + } } async fn get_execution_node() -> Result { diff --git a/src/main.rs b/src/main.rs index 972f1bb..64b2b1f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,6 +57,11 @@ struct Common { /// i.e. `ssh ` should work. #[clap(long, env = "FRONTEND_HOSTNAME")] frontend_hostname: Option, + + /// cluster username, needed if running locally with differing usernames + #[clap(long, env = "CLUSTER_USERNAME")] + cluster_username: Option, + } #[derive(Debug, Subcommand)] @@ -240,12 +245,13 @@ async fn context_from_common(common: &Common) -> Result { common.job_id, common.infer_job_id, common.frontend_hostname.clone(), + common.cluster_username.clone() ) .await?; if let ExecutionNode::Machine(_) = ctx.node { tracing::warn!( - "executing oar-p2p from a job machine is not currently support, run from the frontend or your own machine" + "executing oar-p2p from a job machine is not currently supported, run from the frontend or your own machine" ); } @@ -261,7 +267,7 @@ async fn cmd_net_up(args: NetUpArgs) -> Result<()> { ); let matrix_content = tokio::fs::read_to_string(&args.latency_matrix) .await - .context("reading latecy matrix")?; + .context("reading latency matrix")?; tracing::debug!("parsing latency matrix"); let matrix = LatencyMatrix::parse(&matrix_content, latency_matrix::TimeUnit::Milliseconds) @@ -821,6 +827,10 @@ async fn machine_run( arguments.extend(ssh_common); arguments.push("-J"); arguments.push(frontend); + if ctx.cluster_username().is_ok() { + arguments.push("-l"); + arguments.push(ctx.cluster_username()?); + } arguments.push(machine.hostname()); arguments } -- cgit