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

Failed test when the path in cgroups informations have ":" #81977

Closed
1 task done
dvaumoron opened this issue Oct 15, 2023 · 3 comments · Fixed by #82040
Closed
1 task done

Failed test when the path in cgroups informations have ":" #81977

dvaumoron opened this issue Oct 15, 2023 · 3 comments · Fixed by #82040
Assignees
Labels
bug This issue/PR relates to a bug. has_pr This issue has an associated PR.

Comments

@dvaumoron
Copy link

dvaumoron commented Oct 15, 2023

Summary

Get ValueError: too many values to unpack (expected 3) in line cid, subsystem, path = value.split(':') with ansible test

at

cid, subsystem, path = value.split(':')

data come from

stdout = run_utility_container(args, 'ansible-test-probe', cmd, options)[0]

Is it possible to change the line to have something like :

cid, subsystem, path = value.split(':', maxsplit=2)

(edited after a better analysis of the problem)

Issue Type

Bug Report

Component Name

cgroup.py

Ansible Version

ansible-8.5.0
ansible-core-2.15.5

Configuration

problem and solution already in Summary

OS / Environment

cluster K8S/CRI-O with Screwdriver

Steps to Reproduce

problem and solution already in Summary

Expected Results

problem and solution already in Summary

Actual Results

problem and solution already in Summary

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. labels Oct 15, 2023
@ansibot
Copy link
Contributor

ansibot commented Oct 15, 2023

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the component bot command.

@dvaumoron dvaumoron changed the title Failed test when cgroups have additionnal informations Failed test when the path in cgroups informations have ":" Oct 16, 2023
@samuel-phan
Copy link

samuel-phan commented Oct 17, 2023

To give more context, here's the error we got:

+ ansible-test sanity --color -v --junit --docker default --docker-terminate always --python 3.11 --coverage
Configured locale: C.UTF-8
Run command: docker -v
Detected "docker" container runtime version: Docker version 24.0.6, build ed223bc
Run command: docker info --format '{{ json . }}'
Run command: docker version --format '{{ json . }}'
Container runtime: docker client=24.0.6 server=24.0.6 cgroup=v1
Run command: docker image inspect quay.io/ansible/ansible-test-utility-container:2.0.0
Run command: docker run --volume /sys/fs/cgroup:/probe:ro --name ansible-test-probe-GSQSSpzi --rm quay.io/ansible/ansible-test-utility-container:2.0.0 sh -c 'audit-status && cat /proc/sys/fs/nr_o ...
ERROR: Host DockerConfig(python=NativePythonConfig(version='3.11', path='/usr/bin/python3.11'), name='default', image='quay.io/ansible/default-test-container:7.14.0', memory=None, privileged=False, seccomp='default', cgroup=CGroupVersion.V1_V2, audit=AuditMode.REQUIRED) job failed:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/ansible_test/_internal/provisioning.py", line 200, in dispatch_jobs
    thread.wait_for_result()
  File "/usr/local/lib/python3.11/site-packages/ansible_test/_internal/thread.py", line 44, in wait_for_result
    raise exception[1].with_traceback(exception[2])
  File "/usr/local/lib/python3.11/site-packages/ansible_test/_internal/thread.py", line 34, in run
    self._result.put((self.action(), None))
                      ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ansible_test/_internal/provisioning.py", line 134, in provision
    profile.provision()
  File "/usr/local/lib/python3.11/site-packages/ansible_test/_internal/host_profiles.py", line 455, in provision
    init_config = self.get_init_config()
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ansible_test/_internal/host_profiles.py", line 503, in get_init_config
    self.check_cgroup_requirements()
  File "/usr/local/lib/python3.11/site-packages/ansible_test/_internal/host_profiles.py", line 944, in check_cgroup_requirements
    if (cgroup_v1 := detect_host_properties(self.args).cgroup_v1) != SystemdControlGroupV1Status.VALID:
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ansible_test/_internal/thread.py", line 59, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ansible_test/_internal/docker_util.py", line 326, in detect_host_properties
    cgroups = CGroupEntry.loads(blocks[1])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ansible_test/_internal/cgroup.py", line 58, in loads
    return tuple(cls.parse(line) for line in value.splitlines())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ansible_test/_internal/cgroup.py", line 58, in <genexpr>
    return tuple(cls.parse(line) for line in value.splitlines())
                 ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ansible_test/_internal/cgroup.py", line 47, in parse
    cid, subsystem, path = value.split(':')
    ^^^^^^^^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 3)
FATAL: Host job(s) failed. See previous error(s) for details.

When trying to debug the value, we got these kind of values for cgroups:

10:memory:/kubepods-burstable-poda922ee2d_8799_44fa_8630_36e3577caab3.slice:cri-containerd:e6cd7c4b31d05b9970c5eff52203a9aa3bb25c36866b8d75be9b3e5037af71cc/docker/973ab2f8153bd48b50dfa5f9bce3f88be3508c9794c82934d40940f3bade298a
9:blkio:/kubepods-burstable-poda922ee2d_8799_44fa_8630_36e3577caab3.slice:cri-containerd:e6cd7c4b31d05b9970c5eff52203a9aa3bb25c36866b8d75be9b3e5037af71cc/docker/973ab2f8153bd48b50dfa5f9bce3f88be3508c9794c82934d40940f3bade298a
8:devices:/kubepods-burstable-poda922ee2d_8799_44fa_8630_36e3577caab3.slice:cri-containerd:e6cd7c4b31d05b9970c5eff52203a9aa3bb25c36866b8d75be9b3e5037af71cc/docker/973ab2f8153bd48b50dfa5f9bce3f88be3508c9794c82934d40940f3bade298a
7:pids:/kubepods-burstable-poda922ee2d_8799_44fa_8630_36e3577caab3.slice:cri-containerd:e6cd7c4b31d05b9970c5eff52203a9aa3bb25c36866b8d75be9b3e5037af71cc/docker/973ab2f8153bd48b50dfa5f9bce3f88be3508c9794c82934d40940f3bade298a
6:net_cls,net_prio:/kubepods-burstable-poda922ee2d_8799_44fa_8630_36e3577caab3.slice:cri-containerd:e6cd7c4b31d05b9970c5eff52203a9aa3bb25c36866b8d75be9b3e5037af71cc/docker/973ab2f8153bd48b50dfa5f9bce3f88be3508c9794c82934d40940f3bade298a
5:freezer:/kubepods-burstable-poda922ee2d_8799_44fa_8630_36e3577caab3.slice:cri-containerd:e6cd7c4b31d05b9970c5eff52203a9aa3bb25c36866b8d75be9b3e5037af71cc/docker/973ab2f8153bd48b50dfa5f9bce3f88be3508c9794c82934d40940f3bade298a
4:cpuset:/kubepods-burstable-poda922ee2d_8799_44fa_8630_36e3577caab3.slice:cri-containerd:e6cd7c4b31d05b9970c5eff52203a9aa3bb25c36866b8d75be9b3e5037af71cc/docker/973ab2f8153bd48b50dfa5f9bce3f88be3508c9794c82934d40940f3bade298a
3:cpu,cpuacct:/kubepods-burstable-poda922ee2d_8799_44fa_8630_36e3577caab3.slice:cri-containerd:e6cd7c4b31d05b9970c5eff52203a9aa3bb25c36866b8d75be9b3e5037af71cc/docker/973ab2f8153bd48b50dfa5f9bce3f88be3508c9794c82934d40940f3bade298a
2:perf_event:/kubepods-burstable-poda922ee2d_8799_44fa_8630_36e3577caab3.slice:cri-containerd:e6cd7c4b31d05b9970c5eff52203a9aa3bb25c36866b8d75be9b3e5037af71cc/docker/973ab2f8153bd48b50dfa5f9bce3f88be3508c9794c82934d40940f3bade298a
1:name=systemd:/system.slice/kata-agent.service/kubepods-burstable-poda922ee2d_8799_44fa_8630_36e3577caab3.slice:cri-containerd:e6cd7c4b31d05b9970c5eff52203a9aa3bb25c36866b8d75be9b3e5037af71cc/docker/973ab2f8153bd48b50dfa5f9bce3f88be3508c9794c82934d40940f3bade298a

We're running the ansible-test from inside a K8S pod where Docker is installed (yeah, it's a container running a container).

Normally, for cgroups v1, the format is like so:

       /proc/pid/cgroup (since Linux 2.6.24)
              This file describes control groups to which the process
              with the corresponding PID belongs.  The displayed
              information differs for cgroups version 1 and version 2
              hierarchies.

              For each cgroup hierarchy of which the process is a
              member, there is one entry containing three colon-
              separated fields:

                  hierarchy-ID:controller-list:cgroup-path

              For example:

                  5:cpuacct,cpu,cpuset:/daemons

              The colon-separated fields are, from left to right:

              [1]  For cgroups version 1 hierarchies, this field
                   contains a unique hierarchy ID number that can be
                   matched to a hierarchy ID in /proc/cgroups.  For the
                   cgroups version 2 hierarchy, this field contains the
                   value 0.

              [2]  For cgroups version 1 hierarchies, this field
                   contains a comma-separated list of the controllers
                   bound to the hierarchy.  For the cgroups version 2
                   hierarchy, this field is empty.

              [3]  This field contains the pathname of the control group
                   in the hierarchy to which the process belongs.  This
                   pathname is relative to the mount point of the
                   hierarchy.

Source: https://man7.org/linux/man-pages/man7/cgroups.7.html

We confirm by the way that we're dealing with cgroup v1.

@mattclay mattclay removed the needs_triage Needs a first human triage before being processed. label Oct 19, 2023
@mattclay mattclay self-assigned this Oct 19, 2023
@mattclay
Copy link
Member

@dvaumoron @samuel-phan Thank you for the very thorough bug report. I've opened #82040 to resolve this issue.

@ansibot ansibot added the has_pr This issue has an associated PR. label Oct 19, 2023
@ansible ansible locked and limited conversation to collaborators Nov 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. has_pr This issue has an associated PR.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants