Revert needs-restarting prefers to obtain a boot time from systemd to deal with RTCs running in local time

This reverts commit 046df474c4.

Resolves: RHEL-39775
Related: RHEL-14900
This commit is contained in:
Petr Písař 2024-06-06 14:36:41 +02:00
parent 3f68de1989
commit 8dc1318832
4 changed files with 5 additions and 190 deletions

View File

@ -1,62 +0,0 @@
From 74ed4833064ecfec2ac51471d4dfddc86f64d11b Mon Sep 17 00:00:00 2001
From: Nicola Sella <nsella@redhat.com>
Date: Wed, 13 Mar 2024 13:27:54 +0100
Subject: [PATCH 1/3] needs-restarting: get systemd boot time from
UnitsLoadStartTimestamp
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit: 74de8fe84679e509b16ca1d3f12b7d292210ca27
Resolves: https://issues.redhat.com/browse/RHEL-14900
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
plugins/needs_restarting.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/plugins/needs_restarting.py b/plugins/needs_restarting.py
index 309a216..2662d2d 100644
--- a/plugins/needs_restarting.py
+++ b/plugins/needs_restarting.py
@@ -215,6 +215,11 @@ class ProcessStart(object):
We have two sources from which to derive the boot time. These values vary
depending on containerization, existence of a Real Time Clock, etc.
For our purposes we want the latest derived value.
+ - UnitsLoadStartTimestamp property on /org/freedesktop/systemd1
+ The start time of the service manager, according to systemd itself.
+ Seems to be more reliable than UserspaceTimestamp when the RTC is
+ in local time. Works unless the system was not booted with systemd,
+ such as in (most) containers.
- st_mtime of /proc/1
Reflects the time the first process was run after booting
This works for all known cases except machines without
@@ -225,6 +230,25 @@ class ProcessStart(object):
Does not work on containers which share their kernel with the
host - there the host kernel uptime is returned
"""
+ units_load_start_timestamp = None
+ try:
+ bus = dbus.SystemBus()
+ systemd1 = bus.get_object(
+ 'org.freedesktop.systemd1',
+ '/org/freedesktop/systemd1'
+ )
+ props = dbus.Interface(
+ systemd1,
+ dbus.PROPERTIES_IFACE
+ )
+ units_load_start_timestamp = props.Get(
+ 'org.freedesktop.systemd1.Manager',
+ 'UnitsLoadStartTimestamp'
+ )
+ if units_load_start_timestamp != 0:
+ return int(units_load_start_timestamp / (1000 * 1000))
+ except dbus.exceptions.DBusException as e:
+ logger.debug("D-Bus error getting boot time from systemd: {}".format(e))
proc_1_boot_time = int(os.stat('/proc/1').st_mtime)
if os.path.isfile('/proc/uptime'):
--
2.45.0

View File

@ -1,58 +0,0 @@
From 28f2f9876b85fc73f749ba347b0c280a6acbda7e Mon Sep 17 00:00:00 2001
From: Nicola Sella <nsella@redhat.com>
Date: Wed, 27 Mar 2024 16:34:11 +0100
Subject: [PATCH 2/3] Document needs-restarting boot time
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit: a0ac8717219a1ec9f466162e87f40afa9aa65284
Also, add a warning in the docs if the system is running in RTC
Resolves: https://issues.redhat.com/browse/RHEL-14900
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
doc/needs_restarting.rst | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/doc/needs_restarting.rst b/doc/needs_restarting.rst
index 46cbcb0..379d027 100644
--- a/doc/needs_restarting.rst
+++ b/doc/needs_restarting.rst
@@ -35,6 +35,32 @@ Description
Note that in most cases a process should survive update of its binary and libraries it is using without requiring to be restarted for proper operation. There are however specific cases when this does not apply. Separately, processes often need to be restarted to reflect security updates.
+.. note::
+ Needs restarting will try to guess the boot time using three different methods:
+
+ ``UnitsLoadStartTimestamp``
+ property on ``/org/freedesktop/systemd1``.
+ Works unless the system was not booted with systemd,
+ such as in (most) containers.
+ ``st_mtime of /proc/1``
+ Reflects the time the first process was run after booting
+ This works for all known cases except machines without
+ a RTC - they awake at the start of the epoch.
+ ``/proc/uptime``
+ Seconds field of /proc/uptime subtracted from the current time
+ Works for machines without RTC if the current time is reasonably correct.
+ Does not work on containers which share their kernel with the
+ host - there the host kernel uptime is returned
+
+
+.. warning::
+ When the system is configured to read the RTC time in the local time zone.
+ This mode cannot be fully supported. It will create various problems
+ with time zone changes and daylight saving time adjustments. The RTC
+ time is never updated, it relies on external facilities to maintain it.
+ **If at all possible, use RTC in UTC by calling**
+ ``timedatectl set-local-rtc 0``.
+
-------
Options
-------
--
2.45.0

View File

@ -1,66 +0,0 @@
From a4d62516adc69b01681e6832ae265aa4865e671f Mon Sep 17 00:00:00 2001
From: Evan Goode <mail@evangoo.de>
Date: Wed, 27 Mar 2024 17:47:52 +0000
Subject: [PATCH 3/3] Needs-restarting: punctuation edits
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream commit: 486e9d4d7f03309f3eaf71e297ae956e18357bd8
Resolves: https://issues.redhat.com/browse/RHEL-14900
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
doc/needs_restarting.rst | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/doc/needs_restarting.rst b/doc/needs_restarting.rst
index 379d027..dafcdd1 100644
--- a/doc/needs_restarting.rst
+++ b/doc/needs_restarting.rst
@@ -36,30 +36,30 @@ Description
Note that in most cases a process should survive update of its binary and libraries it is using without requiring to be restarted for proper operation. There are however specific cases when this does not apply. Separately, processes often need to be restarted to reflect security updates.
.. note::
- Needs restarting will try to guess the boot time using three different methods:
+ Needs-restarting will try to guess the boot time using three different methods:
``UnitsLoadStartTimestamp``
- property on ``/org/freedesktop/systemd1``.
+ D-Bus property on ``/org/freedesktop/systemd1``.
Works unless the system was not booted with systemd,
such as in (most) containers.
``st_mtime of /proc/1``
- Reflects the time the first process was run after booting
+ Reflects the time the first process was run after booting.
This works for all known cases except machines without
- a RTC - they awake at the start of the epoch.
+ a RTC—they awake at the start of the epoch.
``/proc/uptime``
- Seconds field of /proc/uptime subtracted from the current time
+ Seconds field of ``/proc/uptime`` subtracted from the current time.
Works for machines without RTC if the current time is reasonably correct.
Does not work on containers which share their kernel with the
- host - there the host kernel uptime is returned
+ host—there, the host kernel uptime is returned.
.. warning::
- When the system is configured to read the RTC time in the local time zone.
- This mode cannot be fully supported. It will create various problems
- with time zone changes and daylight saving time adjustments. The RTC
- time is never updated, it relies on external facilities to maintain it.
- **If at all possible, use RTC in UTC by calling**
- ``timedatectl set-local-rtc 0``.
+ Some systems are configured to read the RTC time in the local time
+ zone. This mode cannot be fully supported. It will create various problems
+ with time zone changes and daylight saving time adjustments. The RTC time
+ is never updated, it relies on external facilities to maintain it. **If at
+ all possible, use RTC in UTC by calling** ``timedatectl set-local-rtc 0``.
+ See ``man timedatectl`` for more information.
-------
Options
--
2.45.0

View File

@ -34,7 +34,7 @@
Name: dnf-plugins-core
Version: 4.3.0
Release: 15%{?dist}
Release: 16%{?dist}
Summary: Core Plugins for DNF
License: GPLv2+
URL: https://github.com/rpm-software-management/dnf-plugins-core
@ -53,9 +53,6 @@ Patch11: 0011-Update-translations-RHEL-9.3.patch
Patch12: 0012-RHEL-6394-Fix-incorrect-spanish-translation-file.patch
Patch13: 0013-Fix-for-issue-with-binary-garbage-in-smaps-files.patch
Patch14: 0014-needs-restarting-Add-microcode_ctl-to-a-reboot-list.patch
Patch15: 0015-needs-restarting-get-systemd-boot-time-from-UnitsLoa.patch
Patch16: 0016-Document-needs-restarting-boot-time.patch
Patch17: 0017-Needs-restarting-punctuation-edits.patch
Patch18: 0018-system-upgrade-change-http-to-https-in-unit-file.patch
BuildArch: noarch
@ -804,6 +801,10 @@ ln -sf %{_mandir}/man1/%{yum_utils_subpackage_name}.1.gz %{buildroot}%{_mandir}/
%endif
%changelog
* Thu Jun 06 2024 Petr Pisar <ppisar@redhat.com> - 4.3.0-16
- Revert needs-restarting prefers to obtain a boot time from systemd to deal
with RTCs running in local time (RHEL-39775)
* Mon May 20 2024 Petr Pisar <ppisar@redhat.com> - 4.3.0-15
- Fix a link to dnf-system-upgrade service documentation (RHEL-13053)