diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/main.rs b/src/main.rs index 68cbbdd..71aae13 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -578,35 +578,27 @@ async fn machine_containers_save_logs( | |||
| 578 | #[tracing::instrument(ret, err, skip(ctx))] | 578 | #[tracing::instrument(ret, err, skip(ctx))] |
| 579 | async fn machine_copy_logs_dir(ctx: &Context, machine: Machine, output_dir: &Path) -> Result<()> { | 579 | async fn machine_copy_logs_dir(ctx: &Context, machine: Machine, output_dir: &Path) -> Result<()> { |
| 580 | tracing::info!("copying container logs from machine"); | 580 | tracing::info!("copying container logs from machine"); |
| 581 | let scp_common = &[ | ||
| 582 | "-o", | ||
| 583 | "StrictHostKeyChecking=no", | ||
| 584 | "-o", | ||
| 585 | "UserKnownHostsFile=/dev/null", | ||
| 586 | ]; | ||
| 587 | 581 | ||
| 588 | let mut args = vec![]; | 582 | let mut rsync_rsh = format!("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"); |
| 589 | args.extend(scp_common); | ||
| 590 | if ctx.node == ExecutionNode::Unknown { | 583 | if ctx.node == ExecutionNode::Unknown { |
| 591 | args.push("-J"); | 584 | rsync_rsh += &format!(" -J {}", ctx.frontend_hostname()?); |
| 592 | args.push(ctx.frontend_hostname()?); | ||
| 593 | } | 585 | } |
| 594 | args.push("-r"); | ||
| 595 | |||
| 596 | let source_path = format!("{}:/tmp/oar-p2p-logs/*", machine.hostname()); | ||
| 597 | let destination_path = output_dir.display().to_string(); | ||
| 598 | args.push(&source_path); | ||
| 599 | args.push(&destination_path); | ||
| 600 | 586 | ||
| 601 | let output = Command::new("scp").args(args).output().await?; | 587 | let output = Command::new("rsync") |
| 588 | .env("RSYNC_RSH", rsync_rsh) | ||
| 589 | .arg("-avz") | ||
| 590 | .arg(format!("{}:/tmp/oar-p2p-logs/", machine.hostname())) | ||
| 591 | .arg(output_dir.display().to_string()) | ||
| 592 | .output() | ||
| 593 | .await?; | ||
| 602 | let stdout = std::str::from_utf8(&output.stdout).unwrap_or("<invalid utf-8>"); | 594 | let stdout = std::str::from_utf8(&output.stdout).unwrap_or("<invalid utf-8>"); |
| 603 | let stderr = std::str::from_utf8(&output.stderr).unwrap_or("<invalid utf-8>"); | 595 | let stderr = std::str::from_utf8(&output.stderr).unwrap_or("<invalid utf-8>"); |
| 604 | if output.status.success() { | 596 | if output.status.success() { |
| 605 | tracing::trace!("scp stdout:\n{stdout}"); | 597 | tracing::trace!("rsync stdout:\n{stdout}"); |
| 606 | tracing::trace!("scp stderr:\n{stderr}"); | 598 | tracing::trace!("rsync stderr:\n{stderr}"); |
| 607 | } else { | 599 | } else { |
| 608 | tracing::error!("scp stdout:\n{stdout}"); | 600 | tracing::error!("rsync stdout:\n{stdout}"); |
| 609 | tracing::error!("scp stderr:\n{stderr}"); | 601 | tracing::error!("rsync stderr:\n{stderr}"); |
| 610 | } | 602 | } |
| 611 | output.exit_ok()?; | 603 | output.exit_ok()?; |
| 612 | tracing::info!("logs finished copying"); | 604 | tracing::info!("logs finished copying"); |
