Skip to content

Imapsync boot failure due to Mail agent not ready #7910

@DavidePrincipi

Description

@DavidePrincipi

Boot race condition: Imapsync fails if Mail agent is not ready (404 error on reveal-master-credentials).

Steps to reproduce

  • Stop Mail module/agent (simulate a not-ready state at boot)
  • Restart Imapsync service

Expected behavior

Imapsync (or agent.tasks.run()) should wait for Mail agent readiness or implement a retry before aborting the reveal-master-credentials helper script. If the helper fails, Imapsync can still start with the previous password.

Actual behavior

At boot, Imapsync reveal-master-credentials helper immediately executes a Mail task to get the Dovecot master password. If Mail is not started yet, api-server returns 404 and Imapsync startup aborts with error. Rare event but can occur. Example log evidence:

2026-03-01T06:20:23+01:00 [1:imapsync1:systemd] Starting imapsync server...
2026-03-01T06:20:24+01:00 [1:imapsync1:runagent] Traceback (most recent call last):
2026-03-01T06:20:24+01:00 [1:imapsync1:runagent]   File "/home/imapsync1/.config/bin/reveal-master-secret", line 20, in <module>
2026-03-01T06:20:24+01:00 [1:imapsync1:runagent]     response = agent.tasks.run(f"module/{mail_id}", action='reveal-master-credentials')
2026-03-01T06:20:24+01:00 [1:imapsync1:runagent]   File "/usr/local/agent/pypkg/agent/tasks/run.py", line 39, in run
...
2026-03-01T06:20:25+01:00 [1:imapsync1:runagent] aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url='http://cluster-leader:9311/api/module/mail1/tasks'
2026-03-01T06:20:25+01:00 [1:imapsync1:systemd] imapsync.service: Control process exited, code=exited, status=1/FAILURE

Additional context

Ideas:

  1. Fixing the core layer. The retry logic should be implemented by agent.tasks Python library itself. Also api-server 404 response does not describe the situation, we'd consider returning a temporary error code, like 503.
  2. Fixing Imapsync. If the secret can't be obtained, start the service with the old password (and retry later).

Components

  • Core 3.17.1
  • Imapsync 1.2.2
  • Mail (Dovecot) 1.7.5

See also

Metadata

Metadata

Assignees

No one assigned

    Labels

    verifiedAll test cases were verified successfully

    Type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions