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

SystemdService.exists fails with an error due to a malformed command #757

Open
mcdonnnj opened this issue Mar 18, 2024 · 2 comments
Open

Comments

@mcdonnnj
Copy link

The command being run by SystemdService.exists:

cmd = self.run_test('systemctl list-unit-files | grep -q"^%s"', self.name)

does not run successfully as it appears to be malformed. When attempting to use it in a molecule test configuration the following error is seen:

E       AssertionError: Unexpected exit code 2 for CommandResult(backend=<testinfra.backend.docker.DockerBackend object at 0x7f792dec0a70>, exit_status=2, command=b'systemctl list-unit-files | grep -q"^systemd-binfmt"', _stdout=b'', _stderr=b"grep: invalid option -- '^'\nUsage: grep [OPTION]... PATTERNS [FILE]...\nTry 'grep --help' for more information.\n")
E       assert 2 in [0, 1]
E        +  where 2 = CommandResult(backend=<testinfra.backend.docker.DockerBackend object at 0x7f792dec0a70>, exit_status=2, command=b'syst...=b"grep: invalid option -- '^'\nUsage: grep [OPTION]... PATTERNS [FILE]...\nTry 'grep --help' for more information.\n").rc

I verified that I receive the same error if I login to a running test container:

root@debian12-systemd:/# systemctl list-unit-files | grep -q"^systemd-binfmt"
grep: invalid option -- '^'
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
root@debian12-systemd:/# systemctl list-unit-files | grep -q "^systemd-binfmt"
root@debian12-systemd:/# echo $?
0

It appears that #754 fixes this issue in addition to adding testing as verified by both the tests in that PR and my own double-check in the same molecule container:

root@debian12-systemd:/# systemctl list-units --all | grep -q "^[[:space:]]*systemd-binfmt"
root@debian12-systemd:/# echo $?
0
@jsf9k
Copy link

jsf9k commented Apr 30, 2024

I hit this same issue and was able to verify that #754 fixes it. Is there any hope of #754 being merged soon?

jsf9k added a commit to cisagov/ansible-role-systemd-resolved that referenced this issue Apr 30, 2024
This functionality from pytest-testinfra is currently broken.  See
pytest-dev/pytest-testinfra#757 for more details.  Once
pytest-dev/pytest-testinfra#754 has been merged and a new release of
pytest-testinfra is created the Service.exists line can be restored.
jsf9k added a commit to cisagov/ansible-role-systemd-resolved that referenced this issue May 3, 2024
This functionality from pytest-testinfra is currently broken.  See
pytest-dev/pytest-testinfra#757 for more details.  Once
pytest-dev/pytest-testinfra#754 has been merged and a new release of
pytest-testinfra is created the Service.exists line can be restored.
jsf9k added a commit to cisagov/ansible-role-systemd-resolved that referenced this issue May 3, 2024
This functionality from pytest-testinfra is currently broken.  See
pytest-dev/pytest-testinfra#757 for more details.  Once
pytest-dev/pytest-testinfra#754 has been merged and a new release of
pytest-testinfra is created the Service.exists line can be restored.
jsf9k added a commit to cisagov/ansible-role-systemd-resolved that referenced this issue May 3, 2024
This functionality from pytest-testinfra is currently broken.  See
pytest-dev/pytest-testinfra#757 for more details.  Once
pytest-dev/pytest-testinfra#754 has been merged and a new release of
pytest-testinfra is created the Service.exists line can be restored.
jsf9k added a commit to cisagov/ansible-role-systemd-resolved that referenced this issue May 3, 2024
This functionality from pytest-testinfra is currently broken.  See
pytest-dev/pytest-testinfra#757 for more details.  Once
pytest-dev/pytest-testinfra#754 has been merged and a new release of
pytest-testinfra is created the Service.exists line can be restored.
jsf9k added a commit to cisagov/ansible-role-systemd-resolved that referenced this issue May 3, 2024
This functionality from pytest-testinfra is currently broken.  See
pytest-dev/pytest-testinfra#757 for more details.  Once
pytest-dev/pytest-testinfra#754 has been merged and a new release of
pytest-testinfra is created the Service.exists line can be restored.
jsf9k added a commit to cisagov/ansible-role-systemd-resolved that referenced this issue May 3, 2024
This functionality from pytest-testinfra is currently broken.  See
pytest-dev/pytest-testinfra#757 for more details.  Once
pytest-dev/pytest-testinfra#754 has been merged and a new release of
pytest-testinfra is created the Service.exists line can be restored.
jsf9k added a commit to cisagov/ansible-role-systemd-resolved that referenced this issue May 3, 2024
This functionality from pytest-testinfra is currently broken.  See
pytest-dev/pytest-testinfra#757 for more details.  Once
pytest-dev/pytest-testinfra#754 has been merged and a new release of
pytest-testinfra is created the Service.exists line can be restored.
jsf9k added a commit to cisagov/ansible-role-systemd-resolved that referenced this issue May 3, 2024
This functionality from pytest-testinfra is currently broken.  See
pytest-dev/pytest-testinfra#757 for more details.  Once
pytest-dev/pytest-testinfra#754 has been merged and a new release of
pytest-testinfra is created the Service.exists line can be restored.
jsf9k added a commit to cisagov/ansible-role-systemd-resolved that referenced this issue May 3, 2024
This functionality from pytest-testinfra is currently broken.  See
pytest-dev/pytest-testinfra#757 for more details.  Once
pytest-dev/pytest-testinfra#754 has been merged and a new release of
pytest-testinfra is created the Service.exists line can be restored.
jsf9k added a commit to cisagov/ansible-role-systemd-resolved that referenced this issue May 3, 2024
This functionality from pytest-testinfra is currently broken.  See
pytest-dev/pytest-testinfra#757 for more details.  Once
pytest-dev/pytest-testinfra#754 has been merged and a new release of
pytest-testinfra is created the Service.exists line can be restored.
@jsf9k
Copy link

jsf9k commented May 28, 2024

I believe this issue is resolved by #767, which was released in version 10.1.0.

jsf9k added a commit to cisagov/ansible-role-systemd-resolved that referenced this issue May 28, 2024
jsf9k added a commit to cisagov/ansible-role-systemd-resolved that referenced this issue May 28, 2024
jsf9k added a commit to cisagov/ansible-role-systemd-resolved that referenced this issue Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants