Repository: metalbear-co/mirrord (language: rust)

Issue:
mirrord container regression
in https://github.com/metalbear-co/mirrord/pull/2933
There was an improvement of not using execvp, but that actually exposed a bug - when we used execvp we didn't drop the `NamedTempFile`s so they actually persisted, then docker was able to access it.
After the change, mirrord process ends because container starts successfully (supposedly) then layer fails on loading with:
```
2024-11-28 14:29:18 mirrord layer setup failed with Config(TemplateRenderingFailed("Couldn't open template '\"/tmp/mirrord-config.json\"' -> No such file or directory (os error 2)"))
```
since the host file was deleted.


Discussion / hints:

Fix patch:
diff --git a/changelog.d/2944.fixed.md b/changelog.d/2944.fixed.md
new file mode 100644
index 00000000000..f5bf0cfb1b7
--- /dev/null
+++ b/changelog.d/2944.fixed.md
@@ -0,0 +1,1 @@
+Fix race condition with container run caused by regression
diff --git a/mirrord/cli/src/container.rs b/mirrord/cli/src/container.rs
index 1a2afa27a76..0b5042a65ac 100644
--- a/mirrord/cli/src/container.rs
+++ b/mirrord/cli/src/container.rs
@@ -435,7 +435,9 @@ pub(crate) async fn container_command(
         .status()
         .await;
 
-    let _ = composed_config_file.close();
+    if let Err(err) = composed_config_file.keep() {
+        tracing::warn!(?err, "failed to keep composed config file");
+    }
 
     match runtime_command_result {
         Err(err) => {


Test patch: