From d8f5ea2bc3b1d13c5ae79bc5099f107f057f62ab Mon Sep 17 00:00:00 2001 From: wendrul Date: Wed, 16 Apr 2025 13:59:40 +0200 Subject: [PATCH] Fix cloning logic after merge --- .../windmill-worker/src/ansible_executor.rs | 34 +++++++++++++------ flake.nix | 1 + 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/backend/windmill-worker/src/ansible_executor.rs b/backend/windmill-worker/src/ansible_executor.rs index 2048ac0cd7..0e81db9155 100644 --- a/backend/windmill-worker/src/ansible_executor.rs +++ b/backend/windmill-worker/src/ansible_executor.rs @@ -12,7 +12,8 @@ use uuid::Uuid; use windmill_common::{ error, worker::{ - is_allowed_file_location, to_raw_value, write_file, write_file_at_user_defined_location, Connection, WORKER_CONFIG, + is_allowed_file_location, to_raw_value, write_file, write_file_at_user_defined_location, + Connection, WORKER_CONFIG, }, }; use windmill_queue::MiniPulledJob; @@ -47,13 +48,21 @@ async fn clone_repo( job_dir: &str, job_id: &Uuid, worker_name: &str, - db: &sqlx::Pool, + conn: &Connection, mem_peak: &mut i32, canceled_by: &mut Option, w_id: &str, occupancy_metrics: &mut OccupancyMetrics, ) -> error::Result<()> { - let target_path = is_allowed_file_location(job_dir, &repo.target_path)?; + let target_path = is_allowed_file_location(job_dir, &repo.target_path)? + .into_os_string() + .into_string() + .map_err(|_| { + anyhow!( + "Failed to get UTF-8 String for location `{}`", + &repo.target_path + ) + })?; let mut clone_cmd = Command::new(GIT_PATH.as_str()); clone_cmd .current_dir(job_dir) @@ -72,7 +81,7 @@ async fn clone_repo( let clone_cmd_child = start_child_process(clone_cmd, GIT_PATH.as_str()).await?; handle_child( job_id, - db, + conn, mem_peak, canceled_by, clone_cmd_child, @@ -83,6 +92,7 @@ async fn clone_repo( None, false, &mut Some(occupancy_metrics), + None, ) .await?; @@ -102,7 +112,7 @@ async fn clone_repo( let checkout_cmd_child = start_child_process(checkout_cmd, GIT_PATH.as_str()).await?; handle_child( job_id, - db, + conn, mem_peak, canceled_by, checkout_cmd_child, @@ -113,6 +123,7 @@ async fn clone_repo( None, false, &mut Some(occupancy_metrics), + None, ) .await?; } @@ -231,7 +242,7 @@ async fn install_galaxy_collections( let child = start_child_process(galaxy_roles_cmd, ANSIBLE_GALAXY_PATH.as_str()).await?; handle_child( job_id, - db, + conn, mem_peak, canceled_by, child, @@ -242,6 +253,7 @@ async fn install_galaxy_collections( None, false, &mut Some(occupancy_metrics), + None, ) .await?; @@ -387,19 +399,19 @@ pub async fn handle_ansible_job( .await?; } - for repo in r.git_repos { + for repo in &r.git_repos { clone_repo( - &repo, + repo, job_dir, &job.id, worker_name, - db, + conn, mem_peak, canceled_by, - w_id, + &job.workspace_id, occupancy_metrics, ) - .await?; + .await.map_err(|e| anyhow!("Failed to clone git repo `{}`: {e}", repo.url))?; } if let Some(collections) = r.collections.as_ref() { diff --git a/flake.nix b/flake.nix index e8e91c9391..5e50c9fc0e 100644 --- a/flake.nix +++ b/flake.nix @@ -159,6 +159,7 @@ ]; inherit PKG_CONFIG_PATH RUSTY_V8_ARCHIVE; + GIT_PATH = "${pkgs.git}/bin/git"; NODE_ENV = "development"; NODE_OPTIONS = "--max-old-space-size=16384"; DATABASE_URL = "postgres://postgres:changeme@127.0.0.1:5432/";