Skip to content
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

deb rpm: fix v4 migration with restarting service (master) #702

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ migration_from_v4_main_process() {
rm -f /etc/<%= package_dir %>/<%= service_name %>.conf
ln -sf /etc/<%= package_dir %>/<%= compat_service_name %>.conf /etc/<%= package_dir %>/<%= service_name %>.conf
fi
fi
if [ -h /etc/systemd/system/td-agent.service ]; then
if [ -n "$(command -v systemctl)" ]; then
if systemctl is-active <%= compat_service_name %> >/dev/null; then
# Want to restart with new user/group here,
# but to avoid holding file descriptor under /var/log/<%= compat_package_dir %>/,
# delay restarting <%= service_name %> service.
systemctl stop <%= compat_service_name %>
v4migration_with_restart=y
fi
fi
if [ -h /etc/systemd/system/td-agent.service ]; then
if [ -n "$(command -v systemctl)" ]; then
if systemctl is-active <%= compat_service_name %> >/dev/null; then
# Want to restart with new user/group here,
# but to avoid holding file descriptor under /var/log/<%= compat_package_dir %>/,
# delay restarting <%= service_name %> service.
systemctl stop <%= compat_service_name %>
v4migration_with_restart=y
fi
fi
fi
fi
if [ -d /var/log/<%= compat_package_dir %> -a ! -h /var/log/<%= compat_package_dir %> ]; then
# /var/log/<%= compat_package_dir %> migration from v4
Expand Down
42 changes: 21 additions & 21 deletions fluent-package/yum/fluent-package.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -217,29 +217,29 @@ if [ $1 -eq 1 ]; then
rm -f /etc/@PACKAGE_DIR@/@SERVICE_NAME@.conf
ln -sf /etc/@PACKAGE_DIR@/@COMPAT_SERVICE_NAME@.conf /etc/@PACKAGE_DIR@/@SERVICE_NAME@.conf
fi
fi
if systemctl is-enabled @COMPAT_SERVICE_NAME@; then
# It is not enough to systemctl enable fluentd here for taking over enabled service status
# because td-agent %preun disables td-agent so fluentd is also disabled.
touch %{v4migration_enabled_service}
fi
if systemctl is-active @COMPAT_SERVICE_NAME@; then
if getent passwd @COMPAT_SERVICE_NAME@ >/dev/null; then
if ! getent passwd @SERVICE_NAME@ >/dev/null; then
# usermod fails when user process is active, so
# postpone username migration step here. (During %pre
# stage, mismatch of user/group configuration cause
# restarting service failure.)
systemctl stop @COMPAT_SERVICE_NAME@.service
TD_UID=$(id --user @COMPAT_SERVICE_NAME@)
TD_GID=$(getent group @COMPAT_SERVICE_NAME@ | cut -d':' -f3)
/usr/sbin/useradd -u $TD_UID -g $TD_GID -o @SERVICE_NAME@
if systemctl is-enabled @COMPAT_SERVICE_NAME@; then
# It is not enough to systemctl enable fluentd here for taking over enabled service status
# because td-agent %preun disables td-agent so fluentd is also disabled.
touch %{v4migration_enabled_service}
fi
if systemctl is-active @COMPAT_SERVICE_NAME@; then
if getent passwd @COMPAT_SERVICE_NAME@ >/dev/null; then
if ! getent passwd @SERVICE_NAME@ >/dev/null; then
# usermod fails when user process is active, so
# postpone username migration step here. (During %pre
# stage, mismatch of user/group configuration cause
# restarting service failure.)
systemctl stop @COMPAT_SERVICE_NAME@.service
TD_UID=$(id --user @COMPAT_SERVICE_NAME@)
TD_GID=$(getent group @COMPAT_SERVICE_NAME@ | cut -d':' -f3)
/usr/sbin/useradd -u $TD_UID -g $TD_GID -o @SERVICE_NAME@
fi
fi
# Want to restart with new user/group here,
# but to avoid holding file descriptor under /var/log/@COMPAT_PACKAGE_DIR@/,
# delay restarting @SERVICE_NAME@ service.
touch %{v4migration_with_restart}
fi
# Want to restart with new user/group here,
# but to avoid holding file descriptor under /var/log/@COMPAT_PACKAGE_DIR@/,
# delay restarting @SERVICE_NAME@ service.
touch %{v4migration_with_restart}
fi
if [ -d /var/log/@COMPAT_PACKAGE_DIR@ -a ! -h /var/log/@COMPAT_PACKAGE_DIR@ ]; then
# /var/log/@COMPAT_PACKAGE_DIR@ migration from v4
Expand Down