Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible-test - Fix --prime-containers and --explain #79581

Merged
merged 3 commits into from Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions test/lib/ansible_test/_internal/docker_util.py
Expand Up @@ -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

Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -768,6 +774,9 @@ def running(self) -> bool:
@property
def pid(self) -> int:
"""Return the PID of the init process."""
if self.args.explain:
return 0

return self.state['Pid']

@property
Expand Down
5 changes: 5 additions & 0 deletions test/lib/ansible_test/_internal/host_profiles.py
Expand Up @@ -76,6 +76,7 @@
run_utility_container,
SystemdControlGroupV1Status,
LOGINUID_NOT_SET,
UTILITY_IMAGE,
)

from .bootstrap import (
Expand Down Expand Up @@ -455,6 +456,10 @@ def provision(self) -> None:
)

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
Expand Down