-
Notifications
You must be signed in to change notification settings - Fork 159
Use systemd service and timer to upload katello tracer #13505
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
base: rpm/develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../../.git/annex/objects/pG/55/SHA256E-s26387--b7068ad6abd8cfa0c691d0241b8cd5b9448ee9e7b8d2f8768451ead3bc87e58b.tar.gz/SHA256E-s26387--b7068ad6abd8cfa0c691d0241b8cd5b9448ee9e7b8d2f8768451ead3bc87e58b.tar.gz |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,16 @@ | |||||||||||||||
| %global zypper_install (0%{?suse_version} > 0) | ||||||||||||||||
| %global build_tracer 0%{?rhel} >= 7 || 0%{?fedora} || 0%{?suse_version} | ||||||||||||||||
|
|
||||||||||||||||
| %if 0%{?suse_version} | ||||||||||||||||
| %define pkg_systemd_post() %service_add_post %{*} | ||||||||||||||||
| %define pkg_systemd_preun() %service_del_preun %{*} | ||||||||||||||||
| %define pkg_systemd_postun() %service_del_postun %{*} | ||||||||||||||||
| %else | ||||||||||||||||
| %define pkg_systemd_post() %systemd_post %{*} | ||||||||||||||||
| %define pkg_systemd_preun() %systemd_preun %{*} | ||||||||||||||||
| %define pkg_systemd_postun() %systemd_postun %{*} | ||||||||||||||||
| %endif | ||||||||||||||||
|
|
||||||||||||||||
| %if 0%{?suse_version} | ||||||||||||||||
| %define dist suse%{?suse_version} | ||||||||||||||||
| %endif | ||||||||||||||||
|
|
@@ -33,8 +43,8 @@ | |||||||||||||||
| %global katello_libdir %{python_libdir}/katello | ||||||||||||||||
|
|
||||||||||||||||
| Name: katello-host-tools | ||||||||||||||||
| Version: 4.5.0 | ||||||||||||||||
| Release: 2%{?dist} | ||||||||||||||||
| Version: 4.6.0 | ||||||||||||||||
| Release: 1%{?dist} | ||||||||||||||||
| Summary: A set of commands and yum plugins that support a Katello host | ||||||||||||||||
| Group: Development/Languages | ||||||||||||||||
| %if 0%{?suse_version} | ||||||||||||||||
|
|
@@ -54,6 +64,8 @@ BuildArch: noarch | |||||||||||||||
| %endif | ||||||||||||||||
|
|
||||||||||||||||
| Requires: subscription-manager | ||||||||||||||||
| Requires: systemd | ||||||||||||||||
| BuildRequires: systemd-rpm-macros systemd | ||||||||||||||||
| Obsoletes: %{name}-fact-plugin < %{version}-%{release} | ||||||||||||||||
| Obsoletes: katello-agent < %{version}-%{release} | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -98,11 +110,6 @@ BuildArch: noarch | |||||||||||||||
| Summary: Adds Tracer functionality to a client managed by katello-host-tools | ||||||||||||||||
| Group: Development/Languages | ||||||||||||||||
| Requires: %{name} = %{version}-%{release} | ||||||||||||||||
| %if 0%{?suse_version} | ||||||||||||||||
| Requires: cronie | ||||||||||||||||
| %else | ||||||||||||||||
| Requires: crontabs | ||||||||||||||||
| %endif | ||||||||||||||||
| %if %{yum_install} | ||||||||||||||||
| Requires: python2-tracer >= 0.6.12 | ||||||||||||||||
| %endif | ||||||||||||||||
|
|
@@ -208,9 +215,12 @@ mkdir -p %{buildroot}%{_sbindir} | |||||||||||||||
| cp extra/katello-tracer-upload-dnf %{buildroot}%{_sbindir}/katello-tracer-upload | ||||||||||||||||
| %endif | ||||||||||||||||
|
|
||||||||||||||||
| # crontab | ||||||||||||||||
| mkdir -p %{buildroot}%{_sysconfdir}/cron.d/ | ||||||||||||||||
| cp extra/katello-tracer-upload.cron %{buildroot}%{_sysconfdir}/cron.d/katello-tracer-upload | ||||||||||||||||
| # tracer systemd service and timer | ||||||||||||||||
| install -Dp -m0644 extra/katello-tracer-upload.service.in %{buildroot}%{_unitdir}/katello-tracer-upload.service | ||||||||||||||||
| install -Dp -m0644 extra/katello-tracer-upload.timer %{buildroot}%{_unitdir}/katello-tracer-upload.timer | ||||||||||||||||
|
Comment on lines
-213
to
+220
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With cron, you just drop a file to a location and you're done. With systemd timers, you drop the unit definitions, but you then have to enable them. How would that be handled?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure as I'm not yet able to fully test this but I have expected that the %systemd_post macro does enable the service. Need to verify this.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but you need also the timer installed and enabled so
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK, only the timer need to activated. I adapted the spec file accordingly. but actually, I can only fully test it if Katello/katello-host-tools#171 is merged. |
||||||||||||||||
|
|
||||||||||||||||
| # replace @SBIN_PATH@ in the service file with the actual path to the executable | ||||||||||||||||
| sed -i "s|@SBIN_PATH@|%{_sbindir}|" %{buildroot}%{_unitdir}/katello-tracer-upload.service | ||||||||||||||||
| %endif | ||||||||||||||||
|
|
||||||||||||||||
| %clean | ||||||||||||||||
|
|
@@ -223,6 +233,25 @@ katello-enabled-repos-upload 2> /dev/null | |||||||||||||||
| exit 0 | ||||||||||||||||
| %endif | ||||||||||||||||
|
|
||||||||||||||||
| %if %{build_tracer} | ||||||||||||||||
| %post tracer | ||||||||||||||||
| %pkg_systemd_post katello-tracer-upload.timer | ||||||||||||||||
|
|
||||||||||||||||
| if [ "$1" -eq 1 ]; then | ||||||||||||||||
| systemctl enable --now katello-tracer-upload.timer >/dev/null 2>&1 || : | ||||||||||||||||
| fi | ||||||||||||||||
|
|
||||||||||||||||
| %preun tracer | ||||||||||||||||
| %pkg_systemd_preun katello-tracer-upload.timer | ||||||||||||||||
|
|
||||||||||||||||
| if [ "$1" -eq 0 ]; then | ||||||||||||||||
| systemctl disable --now katello-tracer-upload.timer >/dev/null 2>&1 || : | ||||||||||||||||
| fi | ||||||||||||||||
|
Comment on lines
+244
to
+249
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
%preun tracer
%pkg_systemd_preun katello-tracer-upload.timer |
||||||||||||||||
|
|
||||||||||||||||
| %postun tracer | ||||||||||||||||
| %pkg_systemd_postun katello-tracer-upload.timer | ||||||||||||||||
|
Comment on lines
+251
to
+252
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fedora convention is to pass both units so both get proper lifecycle handling: %post tracer
%pkg_systemd_post katello-tracer-upload.service katello-tracer-upload.timer
%preun tracer
%pkg_systemd_preun katello-tracer-upload.service katello-tracer-upload.timer
%postun tracer
%pkg_systemd_postun katello-tracer-upload.service katello-tracer-upload.timerFor reference, logrotate does: |
||||||||||||||||
| %endif | ||||||||||||||||
|
Comment on lines
+251
to
+253
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as for the above postun macro
Suggested change
SUSE |
||||||||||||||||
|
|
||||||||||||||||
| %files | ||||||||||||||||
| %defattr(-,root,root,-) | ||||||||||||||||
| %if 0%{?rhel} == 6 | ||||||||||||||||
|
|
@@ -273,7 +302,6 @@ exit 0 | |||||||||||||||
| %dir %{_usr}/lib/zypp | ||||||||||||||||
| %dir %{_usr}/lib/zypp/plugins | ||||||||||||||||
| %dir %{plugins_dir} | ||||||||||||||||
| %dir %{_sysconfdir}/cron.d/ | ||||||||||||||||
| %{plugins_dir}/tracer_upload.py | ||||||||||||||||
| %else | ||||||||||||||||
| %if %{yum_install} | ||||||||||||||||
|
|
@@ -284,12 +312,17 @@ exit 0 | |||||||||||||||
| %endif | ||||||||||||||||
| %{katello_libdir}/tracer | ||||||||||||||||
| %{plugins_confdir}/tracer_upload.conf | ||||||||||||||||
| %config(noreplace) %attr(0644, root, root) %{_sysconfdir}/cron.d/katello-tracer-upload | ||||||||||||||||
| %{_unitdir}/katello-tracer-upload.service | ||||||||||||||||
| %{_unitdir}/katello-tracer-upload.timer | ||||||||||||||||
| %attr(750, root, root) %{_sbindir}/katello-tracer-upload | ||||||||||||||||
| %endif | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| %changelog | ||||||||||||||||
| * Tue Jun 09 2026 Bernhard Suttner <suttner@atix.de> - 4.6.0-1 | ||||||||||||||||
| - Use systemd timer implementation instead of cron based | ||||||||||||||||
| solution for tracer upload | ||||||||||||||||
|
|
||||||||||||||||
| * Wed Nov 05 2025 Bernhard Suttner <suttner@atix.de> - 4.5.0-2 | ||||||||||||||||
| - Fix missing /etc/cron.d/ dir for SLES / OBS build. | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Fedora,
%systemd_postunexpands to literally nothing (verified from/usr/lib/rpm/macros.d/macros.systemd). This means on package upgrade ($1 >= 1), the timer won't be restarted to pick up changes.Compare with plocate which uses
%systemd_postun_with_restart— that callssystemd-update-helper mark-restart-system-units, which sets aMarkers=+needs-restartflag on the unit. The actual restart is then performed by atransfiletriggerinfrom thesystemdpackage, which runssystemd-update-helper system-reload-restart(daemon-reload +systemctl reload-or-restart --marked) whenever files in/usr/lib/systemd/system/are added or updated.For the SUSE compat wrapper this would need a corresponding
%service_del_postun_with_restartor equivalent — worth checking if SUSE has one, or whether a manualsystemctl try-restartis needed there.Two real-world examples from Fedora rawhide:
plocate (src):
util-linux / fstrim (src):
Note util-linux uses
_with_restarton the timer but plain%systemd_postun(no-op) on the service — they want the timer restarted on upgrade but don't care about restarting the one-shot service itself. Reasonable pattern for katello-tracer-upload too since it's also a one-shot triggered by timer.