Skip to content

Commit 90c3d4c

Browse files
test(drivers): take the Podman userns reference before creating the sandbox
In auto mode Podman gives each running container its own UID range. The ported test ran the reference container while the sandbox still held the first range, so the reference got the next one and the auto rows failed. Run the reference first, as the old playbooks did, and let it pull the base image if it is missing. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
1 parent a6e0c7b commit 90c3d4c

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎tests/suites/drivers/podman/tests/userns.rs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ async fn configured_userns_matches_podman_reference(cx: &mut Context) -> testkit
3535
let userns = Userns::from_env()?;
3636
let engine = Engine::from_env()?;
3737
let image = testkit::base_image();
38+
let reference = reference_uid_map(&engine, userns, &image).await?;
3839

3940
let name = cx.name("pu");
4041
cx.track(&name);
@@ -66,9 +67,6 @@ async fn configured_userns_matches_podman_reference(cx: &mut Context) -> testkit
6667
run.stdout
6768
))
6869
})?;
69-
70-
// The sandbox create pulled the image, so the reference doesn't need to.
71-
let reference = reference_uid_map(&engine, userns, &image).await?;
7270
testkit::ensure!(
7371
sandbox == reference,
7472
"the sandbox UID map differs from Podman's {userns:?} reference:\nexpected:\n{reference}\nactual:\n{sandbox}"

‎tests/support/podman/src/lib.rs‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,14 @@ impl Userns {
8585
}
8686

8787
/// The UID map, normalized by [`normalize_uid_map`], of a container Podman
88-
/// runs from `image` in `userns`. `image` must already be in the engine's
89-
/// store, e.g. because a sandbox was created from it: the container doesn't
90-
/// pull it.
88+
/// runs from `image` in `userns`, pulling `image` if the engine's store
89+
/// doesn't have it. The container is removed before this returns.
90+
///
91+
/// In `auto` mode Podman gives each running container its own range, so call
92+
/// this before creating the sandbox it is compared with. The sandbox then gets
93+
/// the range the removed reference container released.
9194
pub async fn reference_uid_map(engine: &Engine, userns: Userns, image: &str) -> Result<String> {
92-
let mut args = vec!["run", "--rm", "--pull", "never"];
95+
let mut args = vec!["run", "--rm", "--pull", "missing"];
9396
args.extend(userns.podman_args());
9497
args.extend(["--entrypoint", "/bin/cat", image, "/proc/self/uid_map"]);
9598
let output = engine

0 commit comments

Comments
 (0)