From 2f899537e5f8875b0586e377ae13b6aab46a5974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Sun, 16 Aug 2026 00:41:08 +0200 Subject: [PATCH] Allow to ignore volume setup Add new podman pilot option %ignore_missing_volume_path. When provisioning a container with a shared volume setup like --volume /host/path:/container/path or -v /host/path:/container/path, the default action is to stop with an error when the host path does not exist. This option allows to continue even if the host path is missing. This Fixes bsc#1274855 --- doc/podman-pilot.rst | 9 +++++++++ podman-pilot/src/podman.rs | 23 +++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/doc/podman-pilot.rst b/doc/podman-pilot.rst index 5499897..1540b80 100644 --- a/doc/podman-pilot.rst +++ b/doc/podman-pilot.rst @@ -156,6 +156,15 @@ OPTIONS even if there are files missing. This can lead to a non functional instance of course, you have been warned. +%ignore_missing_volume_path + + When provisioning a container with a shared volume setup + like --volume /host/path:/container/path or -v /host/path:/container/path, + the default action is to stop with an error when the host path does + not exist. This option allows to continue even if the host path is + missing. This can lead to a non functional instance of course, you + have been warned. + %interactive Force interactive call style for processes like a shell. diff --git a/podman-pilot/src/podman.rs b/podman-pilot/src/podman.rs index cc256a3..3781d4d 100644 --- a/podman-pilot/src/podman.rs +++ b/podman-pilot/src/podman.rs @@ -224,8 +224,13 @@ pub fn create( // Garbage collect occasionally gc(user)?; + let pilot_options = Lookup::get_pilot_run_options(); + // create the container with configured runtime arguments let var_pattern = Regex::new(r"%([A-Z]+)").unwrap(); + let volume_pattern = Regex::new( + r"(?:^|\s)(?:--volume|-v)(?:\s*=\s*|\s+)([^\s:]+)" + ).unwrap(); for arg in podman.iter().flatten().flat_map(|x| x.splitn(2, ' ')) { let mut arg_value = arg.to_string(); // The value of a variable can contain another %VAR reference. @@ -255,7 +260,22 @@ pub fn create( ); } } - app.arg(arg_value); + let mut use_option = true; + if pilot_options.contains_key("%ignore_missing_volume_path") { + if let Some(capture) = volume_pattern.captures(&arg_value.clone()) { + let host_volume_path = &capture.get(1).unwrap().as_str(); + if ! Path::new(&host_volume_path).exists() { + if Lookup::is_debug() { + debug!("Volume path {} not found", host_volume_path); + debug!("Call option {} skipped", arg_value); + } + use_option = false + } + } + } + if use_option { + app.arg(arg_value); + } }; // set default runtime arguments if none configured @@ -305,7 +325,6 @@ pub fn create( if Lookup::is_debug() { debug!("{:?} {:?}", app.get_program(), app.get_args()); } - let pilot_options = Lookup::get_pilot_run_options(); let mut spinner = None; if pilot_options.contains_key("%progress") { spinner = Some(