Skip to content

Conversation

samdoran
Copy link
Contributor

SUMMARY

Backport of #72337 for Ansible 2.9.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lib/ansible/modules/systemd.py

…e#72337)

A bug existed in systemd 245 that did not properly handle unknown kernel
capabilities gracefully. This resulted in incomplete output when querying
for the service status. It is possible to get service status by other means.
This PR works around this issue by getting service status using other commands
in the event of a failure due to this bug.
(cherry picked from commit db84e2c)

Co-authored-by: Sam Doran <sdoran@redhat.com>
@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 backport This PR does not target the devel branch. bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. system System category labels Oct 26, 2020
@ktdreyer
Copy link
Contributor

I applied this change to ansible-2.9.14-1.fc32. I don't get the generic error any more, but I get a new error message instead: Could not find the requested service krb5kdc: host

@ktdreyer
Copy link
Contributor

The problem is that systemctl list-units will only display loaded units. When I first install the krb5-server package, systemd does not load the krb5kdc.service unit yet. I cannot list it with systemctl list-units 'krb5kdc.*' (or systemctl list-units --all 'krb5kdc.*') until it's "loaded".

Instead of list-units, I can use list-unit-files, and that works.

@samdoran
Copy link
Contributor Author

Hmm, that's unfortunate. list-unit-files took quite a bit longer to execute which is why I went with list-units. I'll work on another fix.

@ktdreyer
Copy link
Contributor

Weird, both list-units and list-unit-files returned almost instantly on my computer. What difference where you seeing?

@samdoran
Copy link
Contributor Author

Anecdotally list-unit-files took a second or two to return while list-units was instant. I didn't do any measuring, though.

@ktdreyer
Copy link
Contributor

Ok, I do see a long delay (3 seconds) when I run list-unit-files with no further arguments. However, the command returns almost instantly when I specify a single service, for example: systemctl list-unit-files chronyd.service

@samdoran
Copy link
Contributor Author

/usr/bin/time -f "%E" systemctl list-unit-files --no-pager --all
...
480 unit files listed.
0:01.11
/usr/bin/time -f "%E" systemctl list-units --no-pager --all
...
394 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
0:00.02

@samdoran
Copy link
Contributor Author

I think I was planning to list everything then investigate the output before I figure out I could have systemd do the filtering work. And by that time I had switched to list-units.

…sible#72363)

list-unit-files will return all files on the system. list-units omits those
that are disabled.

Co-authored-by: Ken Dreyer <ktdreyer@ktdreyer.com>
(cherry picked from commit d611588)
@ktdreyer
Copy link
Contributor

LGTM, thanks.

@samdoran
Copy link
Contributor Author

Thank you so much for helping out with this fix.

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Nov 6, 2020
…ansible#72702)

Related to issue ansible#71528 and PR ansible#72337

Co-authored-by: Martin Polden <mpolden@mpolden.no>
(cherry picked from commit a788ea0)
@ansibot ansibot added needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. labels Dec 3, 2020
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. core_review In order to be merged, this PR must follow the core review workflow. labels Dec 3, 2020
@relrod relrod merged commit 10cc55c into ansible:stable-2.9 Dec 7, 2020
@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Dec 7, 2020
@ansible ansible locked and limited conversation to collaborators Jan 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 backport This PR does not target the devel branch. bug This issue/PR relates to a bug. ci_verified Changes made in this PR are causing tests to fail. module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. system System category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants