agent: fix the issue of setup sandbox pidns

When the sandbox api was enabled, the pasue container
wouldn't be created, thus the shared sandbox pidns
should be fallbacked to the first container's init process,
instead of return any error here.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
This commit is contained in:
Fupan Li
2024-09-18 13:26:34 +08:00
parent 857222af02
commit 71afeccdf1

View File

@@ -1750,7 +1750,7 @@ fn update_container_namespaces(
if !pidns.path.is_empty() {
pid_ns.set_path(Some(PathBuf::from(&pidns.path)));
}
} else {
} else if !sandbox.containers.is_empty() {
return Err(anyhow!(ERR_NO_SANDBOX_PIDNS));
}
}
@@ -2527,14 +2527,6 @@ mod tests {
.unwrap()],
..Default::default()
},
TestData {
namespaces: vec![],
sandbox_pidns_path: None,
use_sandbox_pidns: true,
result: Err(anyhow!(ERR_NO_SANDBOX_PIDNS)),
expected_namespaces: vec![],
..Default::default()
},
TestData {
has_linux_in_spec: false,
result: Err(anyhow!(ERR_NO_LINUX_FIELD)),