agross / dnf-automatic-restart

Restart machine or services after dnf-automatic installed updates
MIT License
40 stars 4 forks source link

Remove dependency on tracer #1

Closed donateur closed 7 years ago

donateur commented 7 years ago

Hello, Great idea - I had been wanting to see if I could write something like this!

While 'tracer' looks like great open source software, would it be possible to use the dnf needs-restarting plugin? I ask because it is already provided in dnf-plugins-core by default.

You might also consider making the system automatically reboot if something really core like 'glibc' is updated, even if the kernel has not been updated.

agross commented 7 years ago

Hi @donateur,

While 'tracer' looks like great open source software, would it be possible to use the dnf needs-restarting plugin?

Not sure. dnf-tracer's output is very easy to handle, and I also wasn't aware of dnf needs-restarting.

I just ran dnf update on one of my machines.

dnf-tracer output

You should restart:
  * Some applications using:
      sudo systemctl restart sshd

  * These applications manually:
      (sd-pam)
      systemd

dnf needs-restarting output:

1 : /usr/lib/systemd/systemd --system --deserialize 16
834 : /usr/lib/systemd/systemd-journald
845 : /usr/sbin/lvmetad -f -t 3600
988 : /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
990 : /usr/sbin/chronyd
1003 : /usr/sbin/rsyslogd -n
1023 : /usr/lib/systemd/systemd-logind
1026 : /usr/sbin/abrtd -d -s
1027 : /usr/lib/polkit-1/polkitd --no-debug
1048 : /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid
1053 : /usr/bin/abrt-dump-journal-oops -fxtD
1054 : /usr/bin/abrt-dump-journal-xorg -fxtD
1076 : /usr/sbin/dmeventd -f
1082 : /usr/sbin/NetworkManager --no-daemon
1102 : /usr/bin/python -Es /usr/sbin/tuned -l -P
1109 : /usr/libexec/docker/docker-containerd-current --listen unix:///run/containerd.sock --shim /usr/libexec/docker/docker-containerd-shim-current
1195 : /usr/bin/python3 -s /usr/bin/fail2ban-server -s /var/run/fail2ban/fail2ban.sock -p /var/run/fail2ban/fail2ban.pid -x -b
1389 : /sbin/dhclient -d -q -sf /usr/libexec/nm-dhcp-helper -pf /var/run/dhclient-ens3.pid -lf /var/lib/NetworkManager/dhclient-f5516462-dd94-3d2d-9369-59f51e4ecc1d-ens3.lease -cf /var/lib/NetworkManager/dhclient-ens3.conf ens3
1782 : /usr/lib/systemd/systemd-machined
4863 : /usr/bin/python /usr/libexec/netdata/plugins.d/python.d.plugin 1
30010 : /usr/lib/systemd/systemd --user
30021 : (sd-pam)
30539 : sshd: agross [priv]
30543 : sshd: agross@pts/0

Any idea how to transform the latter into systemctl restart invocations?

donateur commented 7 years ago

Any idea how to transform the latter into systemctl restart invocations?

No, sorry good point. I had not realised that to do that would really be a lot of work.

It's a pity because I think by including dnf-tracer code for other platforms is included which isn't needed. It's also not a core component which the Fedora project are motivated to keep updated.

When I had first imagined writing a script like yours I was simply going to check for key updates, like kernel, glibc and systemd and then add a crude score based on the number of things reported by "dnf needs-restarting". A high score would have determined if the system would reboot, even if the core components had not.

At the time I wasn't aware of dnf-tracer. I think you've made the right choice! Closing this now.

On a related topic, are you aware that the core "yum-updatesonboot" plugin for RHEL/CentOS has the ability to reboot automatically after updating on boot (in other words, boot, then update and reboot before a user logs in)? I wonder if Red Hat will want to implement similar functionality when preparing RHEL 8, in which case they may produce some code which could be borrowed by this project too.

See https://jsmith.fedorapeople.org/drafts/SMG/html/Software_Management_Guide/Utilidades_YUM.html

agross commented 7 years ago

On a related topic, are you aware that the core "yum-updatesonboot" plugin for RHEL/CentOS

No, I also wasn't aware of this bit. I mostly run Fedora, though.

bexelbie commented 3 years ago

Based on my opening of #15 - I am updating this ticket. It appears you can reverse a pid into a systemd unit as follows:

# dnf needs-restarting 
768 : /usr/lib/polkit-1/polkitd --no-debug 
1048 : podman 
1121 : containers-rootlessport 
1127 : containers-rootlessport-child 
1135 : /usr/bin/conmon --api-version 1 -c 907f9dc8dc33912535eae0d06310f226a5d44f5994ccbb11e6a9fd3668380078 -u 907f9dc8dc33912535eae0d06310f226a5d44f5994ccbb11e6a9fd3668380078 -r /usr/bin/crun -b /home/bexelbie/.local/share/containers/storage/overlay-containers/907f9dc8dc33912535eae0d06310f226a5d44f5994ccbb11e6a9fd3668380078/userdata -p /run/user/1000/containers/overlay-containers/907f9dc8dc33912535eae0d06310f226a5d44f5994ccbb11e6a9fd3668380078/userdata/pidfile -n unifi --exit-dir /run/user/1000/libpod/tmp/exits --full-attach -s -l k8s-file:/home/bexelbie/.local/share/containers/storage/overlay-containers/907f9dc8dc33912535eae0d06310f226a5d44f5994ccbb11e6a9fd3668380078/userdata/ctr.log --log-level warning --runtime-arg --log-format=json --runtime-arg --log --runtime-arg=/run/user/1000/containers/overlay-containers/907f9dc8dc33912535eae0d06310f226a5d44f5994ccbb11e6a9fd3668380078/userdata/oci-log --conmon-pidfile /run/user/1000/containers/overlay-containers/907f9dc8dc33912535eae0d06310f226a5d44f5994ccbb11e6a9fd3668380078/userdata/conmon.pid --exit-command /usr/bin/podman --exit-command-arg --root --exit-command-arg /home/bexelbie/.local/share/containers/storage --exit-command-arg --runroot --exit-command-arg /run/user/1000/containers --exit-command-arg --log-level --exit-command-arg warning --exit-command-arg --cgroup-manager --exit-command-arg systemd --exit-command-arg --tmpdir --exit-command-arg /run/user/1000/libpod/tmp --exit-command-arg --runtime --exit-command-arg crun --exit-command-arg --storage-driver --exit-command-arg overlay --exit-command-arg --events-backend --exit-command-arg journald --exit-command-arg container --exit-command-arg cleanup --exit-command-arg 907f9dc8dc33912535eae0d06310f226a5d44f5994ccbb11e6a9fd3668380078 

# systemctl status 768
● polkit.service - Authorization Manager
     Loaded: loaded (/usr/lib/systemd/system/polkit.service; static)
     Active: active (running) since Tue 2021-10-05 11:42:48 CEST; 6 days ago
       Docs: man:polkit(8)
   Main PID: 768 (polkitd)
      Tasks: 6 (limit: 19144)
     Memory: 20.8M
        CPU: 188ms
     CGroup: /system.slice/polkit.service
             └─768 /usr/lib/polkit-1/polkitd --no-debug

Oct 05 11:42:48 fedora systemd[1]: Starting Authorization Manager...
Oct 05 11:42:48 fedora polkitd[768]: Started polkitd version 0.117
Oct 05 11:42:48 fedora polkitd[768]: Loading rules from directory /etc/polkit-1/rules.d
Oct 05 11:42:48 fedora polkitd[768]: Loading rules from directory /usr/share/polkit-1/rules.d
Oct 05 11:42:48 fedora polkitd[768]: Finished loading, compiling and executing 4 rules
Oct 05 11:42:48 fedora polkitd[768]: Acquired the name org.freedesktop.PolicyKit1 on the system bus
Oct 05 11:42:48 fedora systemd[1]: Started Authorization Manager.
MartinNowak commented 1 year ago

Any idea how to transform the latter into systemctl restart invocations?

dnf needs-restarting --services and dnf needs-restarting --reboothint

DNF needs-restarting Plugin — dnf-plugins-core 4.4.1-1 documentation

Quite attractive to use a dnf-core-plugin instead.