Skip to content

bug: DMS v14 regression - Container restart support may fail due to unclean exit #4150

@polarathene

Description

@polarathene

Subject

Something else that requires developers attention

Description

Since v14 introduced logic for better compatibility with container restarts in #3929 , there has been a regression for unclean container exits. When resuming a container, the old process PID files may still be present in this scenario, such as Dovecot causing a crash loop when supervisorctl tries to start the service.

Lines will be repeatedly spammed to logs /var/log/mail.log and /var/log/syslog like:

2024-08-02T00:14:06.432847+00:00 mail dovecot: master: Fatal: Dovecot is already running with PID 133 (read from /run/dovecot/master.pid)
2024-08-02 00:14:07,133 WARN exited: dovecot (exit status 89; not expected)

To fix this regression, the logic from this setup call will need to be run:

_register_setup_function '_setup_apply_fixes_after_configuration'

function _setup_apply_fixes_after_configuration() {
_log 'trace' 'Removing leftover PID files from a stop/start'
find /var/run/ -not -name 'supervisord.pid' -name '*.pid' -delete
touch /dev/shm/supervisor.sock
_log 'debug' 'Checking /var/mail permissions'
if ! _chown_var_mail_if_necessary; then
_dms_panic__general 'Failed to fix /var/mail permissions'
fi
_log 'debug' 'Removing files and directories from older versions'
rm -rf /var/mail-state/spool-postfix/{dev,etc,lib,pid,usr,private/auth}
_rspamd_get_envs
# /tmp/docker-mailserver/rspamd/dkim
if [[ -d ${RSPAMD_DMS_DKIM_D} ]]; then
_log 'debug' "Ensuring '${RSPAMD_DMS_DKIM_D}' is owned by '_rspamd:_rspamd'"
chown -R _rspamd:_rspamd "${RSPAMD_DMS_DKIM_D}"
fi
}

The logic probably should be relocated to target/scripts/startup/check-stack.sh, and the restart condition branch should still run _check:

else
# container was restarted
_early_variables_setup
_log 'info' 'Container was restarted. Skipping setup routines.'
_log 'info' "Welcome to docker-mailserver ${DMS_RELEASE}"
_register_functions
fi


Originally caught and detailed here: #4146 (comment)

Metadata

Metadata

Labels

area/scriptsbug/solution proposedA bug report, whose bug is confirmed, and an unverified solution was proposedbug/solution verifiedA bug report, whose bug is confirmed and a verified solution was proposedkind/bug/reportA report about a bug

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions