Skip to content

Imapsync boot failure due to Mail agent not ready #7910

Closed
NethServer/ns8-imapsync
#69

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

Activity

  1. added this to the NethServer 8.8 milestone on Mar 6, 2026
  2. moved this from ToDo to In Progress in NethServeron Mar 6, 2026
  3. linked a pull request that will close this issuefix: retry request to Mail #69on Mar 6, 2026
  4. added a commit that references this issue on Mar 6, 2026
  5. removed their assignment
    on Mar 6, 2026
  6. DavidePrincipi commented on Mar 6, 2026

    @DavidePrincipi
    MemberAuthor

    In Testing 1.2.3-dev.1

    Test case

    Check the bug is not reproducible

  7. added
    testing
    on Mar 6, 2026
  8. moved this from In Progress to Testing in NethServeron Mar 6, 2026
  9. mrmarkuz commented on Mar 9, 2026

    @mrmarkuz
    Member

    Test case verified

  10. added
    verified
    on Mar 9, 2026
  11. 10 remaining items

  12. DavidePrincipi commented on Mar 19, 2026

    @DavidePrincipi
    MemberAuthor

    In Testing 1.2.5-dev.1

    Test case

    • Check the bug is not reproducible.
    • Check a warning message is sent to journal every 10 seconds while Mail is down until Systemd unit startup timeout elapses.
  13. added
    testing
    on Mar 19, 2026
  14. moved this from In Progress to Testing in NethServeron Mar 19, 2026
  15. lucagasparini commented on Mar 20, 2026

    @lucagasparini

    Test case on test VPS: OK
    Also installed in production on ticket #199511 (pending confirmation)

  16. lucagasparini commented on May 15, 2026

    @lucagasparini

    Solution also confirmed on the ticket.

  17. added
    verified
    on May 15, 2026
  18. removed
    testing
    on May 15, 2026
  19. moved this from Testing to Verified in NethServeron May 15, 2026
  20. DavidePrincipi commented on May 15, 2026

    @DavidePrincipi
    MemberAuthor
  21. moved this from Verified to Done in NethServeron May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

verified

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions