fix: /var/mail-state should not symlink non-existing directories#4018
fix: /var/mail-state should not symlink non-existing directories#4018polarathene merged 9 commits intomasterfrom
/var/mail-state should not symlink non-existing directories#4018Conversation
…king The Getmail service doesn't have a directory in `/var/lib/` by default, yet `mail-state` is configured to symlink it, and the service in DMS is configured to expect `/var/lib/getmail` exists. Handled in `mail-state` logic to ensure it doesn't silently fail.
|
Existing tests are failing: not ok 30 [Getmail] debug-getmail works as expected in 565ms
# (from function `assert_line' in file test/test_helper/bats-assert/src/assert_line.bash, line 219,
# in test file test/tests/parallel/set1/getmail.bats, line 58)
# `assert_line --regexp 'retriever:.*SimpleIMAPSSLRetriever\(ca_certs="None", certfile="None", getmaildir="\/tmp\/docker-mailserver\/getmail", imap_on_delete="None", imap_search="None", keyfile="None", mailboxes="\(.*INBOX.*\)", move_on_delete="None", ***, password_command="\(\)", port="993", record_mailbox="True", server="imap.remote-service.test", ssl_cert_hostname="None", ssl_ciphers="None", ssl_fingerprints="\(\)", ssl_version="None", timeout="180", use_cram_md5="False", use_kerberos="False", use_peek="True", use_xoauth2="False", username="user3"\)'' failed
#
# -- no output line matches regular expression --
# regexp : retriever:.*SimpleIMAPSSLRetriever\(ca_certs="None", certfile="None", getmaildir="\/tmp\/docker-mailserver\/getmail", imap_on_delete="None", imap_search="None", keyfile="None", mailboxes="\(.*INBOX.*\)", move_on_delete="None", ***, password_command="\(\)", port="993", record_mailbox="True", server="imap.remote-service.test", ssl_cert_hostname="None", ssl_ciphers="None", ssl_fingerprints="\(\)", ssl_version="None", timeout="180", use_cram_md5="False", use_kerberos="False", use_peek="True", use_xoauth2="False", username="user3"\)
# output (22 lines):
# retriever: SimpleIMAPSSLRetriever(ca_certs="None", certfile="None", getmaildir="/var/lib/getmail", imap_on_delete="None", imap_search="None", keyfile="None", mailboxes="('INBOX',)", move_on_delete="None", ***, password_command="()", port="993", record_mailbox="True", server="imap.remote-service.test", ssl_cert_hostname="None", ssl_ciphers="None", ssl_fingerprints="()", ssl_version="None", timeout="180", use_cram_md5="False", use_kerberos="False", use_peek="True", use_xoauth2="False", username="user3")
# destination: MDA_external(allow_root_commands="True", arguments="('-d', '[email protected]')", command="deliver", group="None", ignore_stderr="False", path="/usr/lib/dovecot/deliver", pipe_stdout="True", unixfrom="False", user="None")
# options:
# delete : False
# delete_after : 0
# delete_bigger_than : 0
# delivered_to : False
# fingerprint : False
# logfile : logfile(filename="/var/log/mail/getmail-user3.log")
# max_bytes_per_session : 0
# max_message_size : 0
# max_messages_per_session : 500
# message_log : /var/log/mail/getmail-user3.log
# message_log_syslog : False
# message_log_verbose : False
# netrc_file : None
# read_all : False
# received : False
# skip_imap_fetch_size : False
# to_oldmail_on_each_mail : False
# use_netrc : False
# verbose : 0
# --
#I have no idea why the EC lint is failing, though.. |
|
TL;DR: Seems that
This is due to the logic here: docker-mailserver/target/bin/debug-getmail Lines 10 to 15 in 006f442 Previously since the internal directory never existed in the first place (except I guess as a symlink to nothing) it would fallback to the config volume and configure for that instead... I guess we missed that during review 🤷♂️ It shouldn't store data at locations for different concerns? (runtime state that's usually discardable vs config volume that is generally used to persist anything else) The cronjob (for runtime usage) has the docker-mailserver/target/bin/getmail-cron Lines 3 to 7 in 006f442 More context
Unlike fetchmail, there is no daemon service or polling, thus the cronjob:
RC files are provided via the config volume and copied over to internal location in docker-mailserver/target/scripts/startup/setup.d/getmail.sh Lines 14 to 16 in 006f442 These all have a base config (which our docs advise mounting directly over instead of supporting via the config volume) but to be practical with DMS needs to configure to deliver over to Dovecot: docker-mailserver/test/config/getmail/getmail-user3.cf Lines 1 to 11 in 006f442 I'm not sure why this even needs to be in DMS beyond convenience, there isn't anything specific about it to integrate from the looks of it. Although that's probably the same case with fetchmail. Although there's this interesting FAQ entry from the original getmail author criticizing fetchmail.
So any existing users of the feature either have had mail delivered to Dovecot as per guidance in the docs, or it's been stored in |
|
Hi @polarathene, I'm attempting to switch from fetchmail to getmail and have a question: Why use This directory is used by getmail to store information about emails that have already been downloaded. This is because it retrieves messages based on the server's message ID rather than the 'unread' flag of the message as fetchmail doing. So, this directory serves a "data" purpose, and I believe it should not be located inside the config directory, which is often stored in a Git repository. |
|
You are asking if this location should instead be in Most data there is intended for I can understand that the Config volume is probably not appropriate either. DMS hasn't introduced any other volumes for a long time, this one is usually used for persisting data that isn't logs or I've been thinking an overhaul will need to be considered in future. In the meantime, you are able to volume mount a separate host location over the Perhaps @casperklein or @georglauterbach can weigh in with their opinion. From what @mazzz1y describes the getmail data here is state, but it's state you'd want to persist I don't think it's intended for So like the redis database, it might be better if it were stored at a separate location intended for persisting data. Presently that purpose overlaps with the Open to suggestions, but such changes would need to be queued for v15 as it'd be a breaking change. @mazzz1y you may want to open a new issue and link to the discussion here. Go with |
|
I think it'd be best to store it in |
Yes! This is definitely what is needed. Getmail stores its own state there, and I think /var/mail-state is intended for exactly this purpose (at least by name).
I'm already doing this, but it doesn't look nice :) volumes:
- ./data/maildata:/var/mail
- ./data/mailstate:/var/mail-state
- ./data/getmail:/tmp/docker-mailserver/getmail
- ./config/docker-mailserver:/tmp/docker-mailserverAlso, this method results in Docker creating an empty ./config/docker-mailserver/getmail directory on the host. This happens because the mounting action inside the Docker container requires the creation of an empty directory at /tmp/docker-mailserver/getmail before mounting. It doesn't look good, but it works, so the issue is not a significant one and is more of an aesthetic concern I will create a separate issue |
I might migrate from fetchmail to getmail in mid september. I will then take a closer look at the getmail implementation and possibly improve it, e.g. making it a service that is handled by supervisord instead of the current cron approach. Regarding |
Discussion should probably continue at the new issue for this, so I'll be brief. I recall |
Description
/var/lib/getmail/doesn't seem like it should have been introduced. Drop it in favor of/tmp/docker-mailserver/getmail. It appears to be for storing remote mail that was retrieved if not configured to send to Dovecot like our docs advise. This location was never valid anyway (as referenced issue covers).Fetchmail debug command force enabled the feature to avoid requiring the ENV. Probably before a release when we moved the(EDIT: Sorry lacking time to support this unrelated change due to a test case reliance on it, reverted)setupCLI into the container itself. Since the feature setup script called already gates on the feature ENV toggle and outputs a debug log when disabled... don't implicitly enable the feature.Original message
/var/lib/by default, yetmail-stateis configured to symlink it, and the service in DMS is configured to expect/var/lib/getmailexists.Handled in(EDIT: Just realized this won't solve it due to the condition it's in 😂 )mail-statelogic to ensure it doesn't silently fail.It should probably skip the symlink in this case and omit an error to the logs? Quick fix would be to have the Getmail service startup script itself ensure the directory is configured.
Fixes #4015
Type of change
Checklist
CHANGELOG.md