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

Race condition within loginctl_user type #302

Open
duritong opened this issue Dec 12, 2022 · 0 comments
Open

Race condition within loginctl_user type #302

duritong opened this issue Dec 12, 2022 · 0 comments

Comments

@duritong
Copy link
Contributor

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 7.21.0
  • Ruby: vendored
  • Distribution: CentOS Stream 9
  • Module version: 469b0f2

How to reproduce (e.g Puppet code you use)

I was running puppet on a node and suddenly I got:

Error: Could not prefetch loginctl_user provider 'ruby': Execution of '/bin/loginctl show-user -p Name -p Linger root mail nginx-edge' returned 1: Failed to get user: User ID 8 is not logged in or lingering
Name=root
Linger=no

nginx-edge is a lingering user. mail normally not, BUT user mail has certain systemd timers that are running.

Since managing the lingering state of nginx-edge failed, management of that user failed.

When looking at the code (https://github.com/voxpupuli/puppet-systemd/blob/1d785f129b5b5395860b1d39723e0aa7b31f7c74/lib/puppet/provider/loginctl_user/ruby.rb) we see that it first the currently users and then tries to get more info about them in one shot.

When I ran the first command manually, the user mail did not show up. Also subsequent puppet runs never had that issue anymore.

So what I assume is that at the moment puppet run the first command the user mail had a systemd timer running and thus was active and showed up in the show-user command. BUT when running the second command, the timer was already done and thus the user not anymore active and thus it didn't show up.

What is a bit worse is that the provider errors out and thus everything errors out.

Not really sure how to fix that issue properly, but it can definitely be that you hit that race condition.

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

1 participant