From d9787d1d5bc4c5b255b7e86c554af7737c1c7409 Mon Sep 17 00:00:00 2001 From: Kentaro Hayashi Date: Wed, 23 Oct 2024 17:55:09 +0900 Subject: [PATCH 1/2] deb: don't always fire v4 restart process Before: * if td-agent.service exist and td-agent is active, stop td-agent and force v4 migration with restart process in postinst configure phase. After: * only execute v4 migration with restart process still v4 migration phase in postinst configure phase. It might be a bug for v5.x Signed-off-by: Kentaro Hayashi --- .../fluent-package/deb/postinst | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/fluent-package/templates/package-scripts/fluent-package/deb/postinst b/fluent-package/templates/package-scripts/fluent-package/deb/postinst index 28f2cf024..dee4c4a67 100755 --- a/fluent-package/templates/package-scripts/fluent-package/deb/postinst +++ b/fluent-package/templates/package-scripts/fluent-package/deb/postinst @@ -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 From 52974fa905109650adfeb7fae0ec7fdce39d6899 Mon Sep 17 00:00:00 2001 From: Kentaro Hayashi Date: Wed, 23 Oct 2024 17:55:29 +0900 Subject: [PATCH 2/2] rpm: don't always fire v4 restart process 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 --- fluent-package/yum/fluent-package.spec.in | 42 +++++++++++------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/fluent-package/yum/fluent-package.spec.in b/fluent-package/yum/fluent-package.spec.in index 68f7a01da..0549d7bc7 100644 --- a/fluent-package/yum/fluent-package.spec.in +++ b/fluent-package/yum/fluent-package.spec.in @@ -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