summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2022-12-12 12:12:16 -0800
committerGitHub <noreply@github.com>2022-12-12 12:12:16 -0800
commitda3b1d3f50bfbe118f2200e3e2ef109d87da4c2e (patch)
treee4ed18c9abcd5f85ae4978f698d25d459aeaca06
parentdcc08eec35fde72845d121859abf1ffef1e9030f (diff)
downloadansible-da3b1d3f50bfbe118f2200e3e2ef109d87da4c2e.tar.gz
ansible-test - Fix `--prime-containers` and `--explain` (#79581)
* Remove unused code. * Fix explain errors. * Fix `--prime-containers` with docker on cgroup v2.
-rw-r--r--test/lib/ansible_test/_internal/docker_util.py17
-rw-r--r--test/lib/ansible_test/_internal/host_profiles.py5
2 files changed, 18 insertions, 4 deletions
diff --git a/test/lib/ansible_test/_internal/docker_util.py b/test/lib/ansible_test/_internal/docker_util.py
index fbaca78630..77cdd4ee0f 100644
--- a/test/lib/ansible_test/_internal/docker_util.py
+++ b/test/lib/ansible_test/_internal/docker_util.py
@@ -255,8 +255,6 @@ class ContainerHostProperties:
audit_code: str
max_open_files: int
loginuid: t.Optional[int]
- cgroups: tuple[CGroupEntry, ...]
- mounts: tuple[MountEntry, ...]
cgroup_v1: SystemdControlGroupV1Status
cgroup_v2: bool
@@ -301,6 +299,16 @@ def detect_host_properties(args: CommonConfig) -> ContainerHostProperties:
cmd = ['sh', '-c', ' && echo "-" && '.join(multi_line_commands)]
stdout = run_utility_container(args, f'ansible-test-probe-{args.session_name}', cmd, options)[0]
+
+ if args.explain:
+ return ContainerHostProperties(
+ audit_code='???',
+ max_open_files=MAX_NUM_OPEN_FILES,
+ loginuid=LOGINUID_NOT_SET,
+ cgroup_v1=SystemdControlGroupV1Status.VALID,
+ cgroup_v2=False,
+ )
+
blocks = stdout.split('\n-\n')
values = blocks[0].split('\n')
@@ -383,8 +391,6 @@ def detect_host_properties(args: CommonConfig) -> ContainerHostProperties:
audit_code=audit_code,
max_open_files=hard_limit,
loginuid=loginuid,
- cgroups=cgroups,
- mounts=mounts,
cgroup_v1=cgroup_v1,
cgroup_v2=cgroup_v2,
)
@@ -768,6 +774,9 @@ class DockerInspect:
@property
def pid(self) -> int:
"""Return the PID of the init process."""
+ if self.args.explain:
+ return 0
+
return self.state['Pid']
@property
diff --git a/test/lib/ansible_test/_internal/host_profiles.py b/test/lib/ansible_test/_internal/host_profiles.py
index aa3d1e2ef1..488cfcea80 100644
--- a/test/lib/ansible_test/_internal/host_profiles.py
+++ b/test/lib/ansible_test/_internal/host_profiles.py
@@ -76,6 +76,7 @@ from .docker_util import (
run_utility_container,
SystemdControlGroupV1Status,
LOGINUID_NOT_SET,
+ UTILITY_IMAGE,
)
from .bootstrap import (
@@ -455,6 +456,10 @@ class DockerProfile(ControllerHostProfile[DockerConfig], SshTargetHostProfile[Do
)
if not container:
+ if self.args.prime_containers:
+ if init_config.command or init_probe:
+ docker_pull(self.args, UTILITY_IMAGE)
+
return
self.container_name = container.name