Skip to content

Commit

Permalink
rpm: don't always fire v4 restart process
Browse files Browse the repository at this point in the history
Before:

* if td-agent.service is enabled mark enabled state
* if td-agent.service is active, but fluentd user does not exist,
  stop td-agent and create fluentd user. To make it enabled,
  restart service later.

After:

* only execute v4 migration with restart process
  when v4 migration phase is executed.

It might be a bug for v5.x

Signed-off-by: Kentaro Hayashi <[email protected]>
  • Loading branch information
kenhys committed Oct 31, 2024
1 parent 2d66952 commit c0dde15
Showing 1 changed file with 21 additions and 21 deletions.
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@/@[email protected]
ln -sf /etc/@PACKAGE_DIR@/@[email protected] /etc/@PACKAGE_DIR@/@[email protected]
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 @[email protected]
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

0 comments on commit c0dde15

Please sign in to comment.