Skip to content

Fixes #36973 - Use dnf needs-restarting to collect tracer information #149

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

Merged
merged 2 commits into from
Apr 2, 2024

Conversation

sbernhard
Copy link
Member

@sbernhard sbernhard commented Dec 4, 2023

Copy link

@m-bucher m-bucher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@ehelms
Copy link
Member

ehelms commented Dec 8, 2023

@parthaa @ianballou could one of y'all take a look?

@ianballou
Copy link
Member

Can we get a redmine for this please?

@sbernhard sbernhard changed the title Use dnf needs-restarting to collect tracer information Fixes #36973 - Use dnf needs-restarting to collect tracer information Dec 11, 2023
@ianballou
Copy link
Member

@ehelms I think https://yum.theforeman.org/client/nightly/el7/x86_64/foreman-client-release.rpm might be leading to the wrong repository:

failure: repodata/repomd.xml from foreman-client: [Errno 256] No more mirrors to try.
https://yum.theforeman.org/client/nightly/el7_9/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found

@ehelms
Copy link
Member

ehelms commented Dec 12, 2023

@ehelms I think https://yum.theforeman.org/client/nightly/el7/x86_64/foreman-client-release.rpm might be leading to the wrong repository:

failure: repodata/repomd.xml from foreman-client: [Errno 256] No more mirrors to try.
https://yum.theforeman.org/client/nightly/el7_9/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found

Thanks for the heads up!

@ehelms
Copy link
Member

ehelms commented Dec 14, 2023

@ehelms I think https://yum.theforeman.org/client/nightly/el7/x86_64/foreman-client-release.rpm might be leading to the wrong repository:

failure: repodata/repomd.xml from foreman-client: [Errno 256] No more mirrors to try.
https://yum.theforeman.org/client/nightly/el7_9/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found

Thanks for the heads up!

The fix is now deployed and the tests are passing for EL7.

from katello.tracer.SystemdDbus import SystemdDbus

STATIC_SERVICES = [
"systemd",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbernhard sbernhard force-pushed the use_dnf branch 3 times, most recently from a060d5b to 086dc5a Compare December 27, 2023 13:07
@ianballou
Copy link
Member

As an aside, I had to hack my system by copying the /usr/local/bin/katello-tracer-upload to /usr/sbin/katello-tracer-upload and /etc/cron.d/katello-tracer-upload to ensure that the dnf plugin would call the new code.

Copy link
Member

@ianballou ianballou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my comments above, I'd like to know if this issue with session traces is a surprise or not. Perhaps it was tested with a different client package upgrade?

@sbernhard
Copy link
Member Author

Based on my comments above, I'd like to know if this issue with session traces is a surprise or not. Perhaps it was tested with a different client package upgrade?

I have tested this some time ago and session traces were recognized by https://github.com/Katello/katello-host-tools/pull/149/files#diff-21052bd00993aa53f643b56c70d49991ad54e23c97da7378b12a0b5b31197e28R36

The is_session is similar to https://github.com/FrostyX/tracer/blob/master/tracer/resources/processes.py#L268

See also this comment: #149 (comment)

Ah, maybe I just missed this one to grab: https://github.com/FrostyX/tracer/blob/ff8fc924fcbe2f638dd88b50549813dab2b8595b/tracer/resources/applications.py#L208

@ianballou
Copy link
Member

Ah, maybe I just missed this one to grab: https://github.com/FrostyX/tracer/blob/ff8fc924fcbe2f638dd88b50549813dab2b8595b/tracer/resources/applications.py#L208

Wow, I am surprised there is such specialized logic in there for ssh sessions. Nice catch!

@ianballou
Copy link
Member

@sbernhard after your update, I'm still seeing the same issue with ssh. The packages I'm playing with are:

[root@rhel9 katello-host-tools]# rpm -qa | grep ssh
libssh-config-0.10.4-8.el9.noarch
libssh-0.10.4-8.el9.x86_64
openssh-8.7p1-34.el9.x86_64
openssh-clients-8.7p1-34.el9.x86_64
openssh-server-8.7p1-34.el9.x86_64

Tracer is still showing:

[root@rhel9 katello-host-tools]# tracer -a
You should restart:
  * Some applications using:
      sudo systemctl restart NetworkManager

  * These applications restarting your session:
      ssh-vagrant-session

but I'm not seeing the session info yet. Is there any debugging / log statements you'd like me to try to help figure out what's going wrong?

@sbernhard
Copy link
Member Author

@sbernhard after your update, I'm still seeing the same issue with ssh. The packages I'm playing with are:

[root@rhel9 katello-host-tools]# rpm -qa | grep ssh
libssh-config-0.10.4-8.el9.noarch
libssh-0.10.4-8.el9.x86_64
openssh-8.7p1-34.el9.x86_64
openssh-clients-8.7p1-34.el9.x86_64
openssh-server-8.7p1-34.el9.x86_64

Tracer is still showing:

[root@rhel9 katello-host-tools]# tracer -a
You should restart:
  * Some applications using:
      sudo systemctl restart NetworkManager

  * These applications restarting your session:
      ssh-vagrant-session

but I'm not seeing the session info yet. Is there any debugging / log statements you'd like me to try to help figure out what's going wrong?

Added some more handling for ssh sessions https://github.com/Katello/katello-host-tools/pull/149/files#diff-21052bd00993aa53f643b56c70d49991ad54e23c97da7378b12a0b5b31197e28R29

Similar to https://github.com/FrostyX/tracer/blob/master/tracer/resources/processes.py#L79

@ianballou
Copy link
Member

Awesome, I'll give it a re-test

@ianballou
Copy link
Member

Session is working now!
image

@ianballou
Copy link
Member

Just need to check the static type and also test on EL7 to make sure the legacy stuff isn't broken.

@ianballou
Copy link
Member

Another photo of the traces working on EL9:
image

@ianballou
Copy link
Member

I'm a little confused why sudo is being marked as a daemon that needs restarting.

Here is the tracer -a output:

You should restart:
  * Some applications using:
      sudo systemctl restart NetworkManager
      sudo systemctl restart auditd
      sudo systemctl restart chronyd
      sudo systemctl restart crond
      sudo systemctl restart dbus-broker
      sudo systemctl restart gssproxy
      sudo systemctl restart irqbalance
      sudo systemctl restart rhsmcertd
      sudo systemctl restart rpcbind
      sudo systemctl restart sshd
      sudo systemctl restart systemd-journald
      sudo systemctl restart systemd-logind
      sudo systemctl restart systemd-udevd

  * These applications manually:
      (sd-pam)

  * These applications restarting your session:
      bash
      getty@tty1
      ssh-vagrant-session

  * These applications rebooting your computer:
      systemd

Here is the dnf needs-restarting output:

[root@rhel9 katello-host-tools]# dnf needs-restarting
Updating Subscription Management repositories.
1 : /usr/lib/systemd/systemd --system --deserialize 42 
534 : /usr/bin/rpcbind -w -f 
538 : /sbin/auditd 
559 : /usr/sbin/NetworkManager --no-daemon 
564 : /usr/lib/systemd/systemd-logind 
570 : /usr/sbin/chronyd -F 2 
574 : /usr/bin/dbus-broker-launch --scope system --audit 
578 : dbus-broker --log 4 --controller 9 --machine-id 1d74ad9f991d4d3eb78e0b2f33e7d45c --max-bytes 536870912 --max-fds 4096 --max-matches 131072 --audit 
587 : /usr/bin/rhsmcertd 
603 : /sbin/agetty -o -p -- \u --noclear - linux 
1950 : sshd: vagrant [priv] 
1954 : /usr/lib/systemd/systemd --user 
1957 : (sd-pam) 
1964 : sshd: vagrant@pts/0  
1965 : -bash 
1985 : sudo -i -u root 
1987 : -bash 
2068 : /usr/sbin/anacron -s

Also (sd-pam) seems to be an outlier since it's not a service. The old tracer reports it as needing "manual restart".

Here's it in systemctl status

           └─user.slice
             └─user-1000.slice
               ├─session-5.scope
               │ ├─ 1950 "sshd: vagrant [priv]"
               │ ├─ 1964 "sshd: vagrant@pts/0"
               │ ├─ 1965 -bash
               │ ├─ 1985 sudo -i -u root
               │ ├─ 1987 -bash
               │ ├─23256 systemctl status
               │ └─23257 less
               └─[email protected]
                 └─init.scope
                   ├─1954 /usr/lib/systemd/systemd --user
                   └─1957 "(sd-pam)"

@ianballou
Copy link
Member

I'm thinking sudo might count under the session type?

@ianballou
Copy link
Member

It looks like with old tracer, sudo is ignored:

image

vs

[root@rhel7 katello-host-tools]# tracer -a
You should restart:
  * Some applications using:
      sudo systemctl restart NetworkManager
      sudo systemctl restart NetworkManager
      sudo systemctl restart chronyd
      sudo systemctl restart crond
      sudo systemctl restart gssproxy
      sudo systemctl restart irqbalance
      sudo systemctl restart polkit
      sudo systemctl restart rhsmcertd
      sudo systemctl restart rpcbind
      sudo systemctl restart rsyslog
      sudo systemctl restart sshd
      sudo systemctl restart systemd-journald
      sudo systemctl restart systemd-logind
      sudo systemctl restart systemd-udevd
      sudo systemctl restart tuned

  * These applications manually:
      sudo

  * These applications restarting your session:
      bash
      getty@tty1
      ssh-vagrant-session

  * These applications rebooting your computer:
      dbus
      kernel
      systemd

This is on EL7.

@ianballou
Copy link
Member

I think anything that the old tracer puts under the "manual restart" category can be ignored, like (sd-pam) and sudo.

@sbernhard
Copy link
Member Author

I have added a workaround @ianballou

Copy link
Member

@ianballou ianballou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking pretty much perfect! Just one small addition:

@ianballou
Copy link
Member

Looking good, doing some final checks

image

Copy link
Member

@ianballou ianballou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, looking good to me!

@jeremylenz
Copy link
Member

@sbernhard can you please fix the Redmine issue and/or squash? :)

@ianballou ianballou merged commit 1408cbd into Katello:master Apr 2, 2024
@ianballou
Copy link
Member

@sbernhard can you please fix the Redmine issue and/or squash? :)

I took care of it during the squash merge 👍

@jeremylenz
Copy link
Member

oh right, of course squash fixes that 🙈

@maximiliankolb maximiliankolb deleted the use_dnf branch September 10, 2024 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants