Skip to content

Commit

Permalink
deb: suppress service restart by needrestart
Browse files Browse the repository at this point in the history
Since Ubuntu 24.04, needrestart package kicks service
restart out of package maintainer scripts.
Take back fluentd service under control for us,
it had better to suppress it.

NOTE: It seems that needrestart package is available from
EPEL 8/9, but it is broken for a long time, so just ignore it.

Needrestart package missing dependency
https://bugzilla.redhat.com/show_bug.cgi?id=2154293

Signed-off-by: Kentaro Hayashi <[email protected]>
Co-authored-by: Shizuo Fujita <[email protected]>
  • Loading branch information
kenhys and Watson1978 committed Dec 5, 2024
1 parent c8419c4 commit 182857a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
19 changes: 15 additions & 4 deletions fluent-package/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -1158,10 +1158,21 @@ class BuildTask
fluentd_conf = "etc/#{PACKAGE_DIR}/#{SERVICE_NAME}.conf"
fluentd_conf_default = "opt/#{PACKAGE_DIR}/share/#{SERVICE_NAME}.conf"
configs = [fluentd_conf]
configs.concat([
"etc/logrotate.d/#{SERVICE_NAME}",
fluentd_conf_default,
]) unless windows? || macos?
unless windows? || macos?
configs.concat([
"etc/logrotate.d/#{SERVICE_NAME}",
fluentd_conf_default,
])
File.readlines("/etc/os-release").each do |line|
if line.include?("ID=")
distribution = line.split(/=/).last.chomp
if ["debian", "ubuntu"].include?(distribution)
puts "Suppress needrestart on #{distribution}"
configs.concat(["etc/needrestart/conf.d/50-fluent-package.conf"])
end
end
end
end
configs.each do |config|
src =
if config == fluentd_conf_default
Expand Down
14 changes: 13 additions & 1 deletion fluent-package/apt/systemd-test/update-from-v4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@ case $1 in
local)
sudo apt install -V -y \
/host/${distribution}/pool/${code_name}/${channel}/*/*/fluent-package_*_${architecture}.deb \
/host/${distribution}/pool/${code_name}/${channel}/*/*/td-agent_*_all.deb
/host/${distribution}/pool/${code_name}/${channel}/*/*/td-agent_*_all.deb 2>&1 | tee upgrade.log
# Test: needrestart was suppressed
if dpkg-query --show --showformat='${Version}' needrestart ; then
case $code_name in
focal)
# dpkg-query succeeds even though needrestart is not installed.
(! grep "No services need to be restarted." upgrade.log)
;;
*)
grep "No services need to be restarted." upgrade.log
;;
esac
fi
;;
v5)
curl --fail --silent --show-error --location https://toolbelt.treasuredata.com/sh/install-${distribution}-${code_name}-fluent-package5.sh | sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,20 @@ fi
main_pid=$(systemctl show --value --property=MainPID fluentd)

# Install the dummy package
sudo apt install -V -y ./next_version.deb
sudo apt install -V -y ./next_version.deb 2>&1 | tee upgrade.log

# Test: needrestart was suppressed
if dpkg-query --show --showformat='${Version}' needrestart ; then
case $code_name in
focal)
# dpkg-query succeeds even though needrestart is not installed.
(! grep "No services need to be restarted." upgrade.log)
;;
*)
grep "No services need to be restarted." upgrade.log
;;
esac
fi

# The service should take over the state
if [ "$enabled_before_update" = enabled ]; then
Expand Down
1 change: 1 addition & 0 deletions fluent-package/debian/fluent-package.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ usr/lib/tmpfiles.d/*
etc/logrotate.d/*
etc/fluent/*
etc/default/*
etc/needrestart/conf.d/*
lib/systemd/system/*
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Configuration for needrestart

# Always suppress restarting by needrestart.
$nrconf{blacklist_rc} = [
qr(^fluentd\.service$)
];

0 comments on commit 182857a

Please sign in to comment.