aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjbordalo <[email protected]>2026-02-11 13:59:59 +0000
committerjbordalo <[email protected]>2026-02-11 13:59:59 +0000
commit5e5448bdd899ba9ba263200616a348acda5eb0ed (patch)
tree08f273d3f7dedc1f044ad7017119718f6b10bfb5 /src
parent62e24e5a18b7041717668dff780bd923d0506c47 (diff)
Add support for differing username between cluster and local machine
Diffstat (limited to 'src')
-rw-r--r--src/context.rs9
-rw-r--r--src/main.rs14
2 files changed, 21 insertions, 2 deletions
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 {
15 job_id: Option<u32>, 15 job_id: Option<u32>,
16 infer_job_id: bool, 16 infer_job_id: bool,
17 frontend_hostname: Option<String>, 17 frontend_hostname: Option<String>,
18 cluster_username: Option<String>
18} 19}
19 20
20impl Context { 21impl Context {
@@ -22,12 +23,14 @@ impl Context {
22 job_id: Option<u32>, 23 job_id: Option<u32>,
23 infer_job_id: bool, 24 infer_job_id: bool,
24 frontend_hostname: Option<String>, 25 frontend_hostname: Option<String>,
26 cluster_username: Option<String>
25 ) -> Result<Self> { 27 ) -> Result<Self> {
26 Ok(Self { 28 Ok(Self {
27 node: get_execution_node().await?, 29 node: get_execution_node().await?,
28 job_id, 30 job_id,
29 infer_job_id, 31 infer_job_id,
30 frontend_hostname, 32 frontend_hostname,
33 cluster_username
31 }) 34 })
32 } 35 }
33 36
@@ -57,6 +60,12 @@ impl Context {
57 .as_deref() 60 .as_deref()
58 .ok_or_else(|| eyre::eyre!("missing frontend hostname")) 61 .ok_or_else(|| eyre::eyre!("missing frontend hostname"))
59 } 62 }
63
64 pub fn cluster_username(&self) -> Result<&str> {
65 self.cluster_username
66 .as_deref()
67 .ok_or_else(|| eyre::eyre!("missing cluster username"))
68 }
60} 69}
61 70
62async fn get_execution_node() -> Result<ExecutionNode> { 71async fn get_execution_node() -> Result<ExecutionNode> {
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 {
57 /// i.e. `ssh <frontend-hostname>` should work. 57 /// i.e. `ssh <frontend-hostname>` should work.
58 #[clap(long, env = "FRONTEND_HOSTNAME")] 58 #[clap(long, env = "FRONTEND_HOSTNAME")]
59 frontend_hostname: Option<String>, 59 frontend_hostname: Option<String>,
60
61 /// cluster username, needed if running locally with differing usernames
62 #[clap(long, env = "CLUSTER_USERNAME")]
63 cluster_username: Option<String>,
64
60} 65}
61 66
62#[derive(Debug, Subcommand)] 67#[derive(Debug, Subcommand)]
@@ -240,12 +245,13 @@ async fn context_from_common(common: &Common) -> Result<Context> {
240 common.job_id, 245 common.job_id,
241 common.infer_job_id, 246 common.infer_job_id,
242 common.frontend_hostname.clone(), 247 common.frontend_hostname.clone(),
248 common.cluster_username.clone()
243 ) 249 )
244 .await?; 250 .await?;
245 251
246 if let ExecutionNode::Machine(_) = ctx.node { 252 if let ExecutionNode::Machine(_) = ctx.node {
247 tracing::warn!( 253 tracing::warn!(
248 "executing oar-p2p from a job machine is not currently support, run from the frontend or your own machine" 254 "executing oar-p2p from a job machine is not currently supported, run from the frontend or your own machine"
249 ); 255 );
250 } 256 }
251 257
@@ -261,7 +267,7 @@ async fn cmd_net_up(args: NetUpArgs) -> Result<()> {
261 ); 267 );
262 let matrix_content = tokio::fs::read_to_string(&args.latency_matrix) 268 let matrix_content = tokio::fs::read_to_string(&args.latency_matrix)
263 .await 269 .await
264 .context("reading latecy matrix")?; 270 .context("reading latency matrix")?;
265 271
266 tracing::debug!("parsing latency matrix"); 272 tracing::debug!("parsing latency matrix");
267 let matrix = LatencyMatrix::parse(&matrix_content, latency_matrix::TimeUnit::Milliseconds) 273 let matrix = LatencyMatrix::parse(&matrix_content, latency_matrix::TimeUnit::Milliseconds)
@@ -821,6 +827,10 @@ async fn machine_run(
821 arguments.extend(ssh_common); 827 arguments.extend(ssh_common);
822 arguments.push("-J"); 828 arguments.push("-J");
823 arguments.push(frontend); 829 arguments.push(frontend);
830 if ctx.cluster_username().is_ok() {
831 arguments.push("-l");
832 arguments.push(ctx.cluster_username()?);
833 }
824 arguments.push(machine.hostname()); 834 arguments.push(machine.hostname());
825 arguments 835 arguments
826 } 836 }