feat: add IMAP IDLE support for getmail - #4675
brainkiller wants to merge 2 commits into
Conversation
|
Documentation preview for this PR is ready! 🎉 Built with commit: b9477ef |
|
Thank you for your contribution. Just wanted to let you know, that we are quiet busy and review will take same time. |
|
I will also take a look, but all PRs are currently blocked for me because of #4536 |
|
Oh I thought this was scheduled for v16 😓 I've had a glance over the PR diff but I would like to try take a simpler approach which I've outlined here: #4713 (comment) That's dependent upon upstream and DMS switching back to using the PyPi package instead of the Debian one to benefit from that. Taking the approach I've outlined would roughly reduce down to this: [program:getmail-parallel]
numprocs = 2
numprocs_start = 1
process_name = %(program_name)s-%(process_num)s
autorestart = true
stopasgroup = true
command = bash -c 'getmail --getmaildir /var/lib/getmail --rcfile getmailrc-account-%(process_num)s && sleep %(ENV_GETMAIL_POLL)sm'NOTE: Until such a PR is feasible, any DMS user could add the above as a config mount into For the IDLE support, add the Or adapt the approach you've got here. It's just more of a hassle to merge a feature when it could be greatly simplified by getting support for the idle setting in config files upstream 😅 |
|
I spent more time on investigating this integration with upstream.
The latest unreleased Getmail commits have added the ability to use Arguably the feature itself as I have described it (and as it is vaguely documented at the Getmail6 project) is in itself broken and not working as implied/documented. Furthermore, I'd like to know the benefit of enabling/supporting IDLE, given the single mailbox limitation?
I assume it's very few remote accounts and quite possibly only the default INBOX being monitored. I'm just curious how important the feature actually is to you, or if it's more of just an ick with polling often instead of receiving a notification from the remote server? Related history for Fetchmail idle support:
|
|
Personally I don't consider the single folder a limitation. The issue I find with polling is that you need to get the interval down to a minute maximum. |
Fair enough, thank you :)
I've yet to get around to filing a bug report properly upstream, but I have pointed it out to the maintainer already that the It is designed to specify a mailbox to receive a notification about updates from, and yet there's no documentation to note that configuring that alone is insufficient if your mailbox is not As this PR lacks a test case for catching that, users are just as likely to make that mistake unaware of it (I'm kind of surprised that it hasn't been raised as a bug report upstream thus far, but perhaps nobody is bothering to use Getmail with mailboxes other than INBOX 🤷♂️) I'll return to this PR after I've approved the Dovecot 2.4 / Debian 13 upgrade PR. I'd much prefer convincing upstream to improve so integration in DMS has reduced complexity. Apologies for the delay that causes here, but thus far I think you're the only user that's requested support for the feature in DMS 😅 I don't mind supporting integrations that can justify the convenience for users well enough, but I also would very much like it done right so that it's minimal burden to maintainers to carry. |
|
@brainkiller It took me a while, but we are now ready to look at this PR again. Please rebase onto the latest Note: In general, a discussion is not sufficient to get a new feature in like that because it's likely to be unnoticed by maintainers like me. But looking at the discussion at hand, I think it's fair. Please open an issue next time, though :) |
|
Damn looks like I closed this PR accidently while trying to re-base. I'm re-opening it with my proposed changes |
|
No worries, I'll be looking into it shortly. |
georglauterbach
left a comment
There was a problem hiding this comment.
Requesting changes for two blocking issues: GETMAIL_IDLE account matching is a substring glob (wrong configs/mailboxes can get --idle), and _filter_service_log now looks inside the container, which redirects other test suites away from /var/log/mail. Inline comments have the details.
| done | ||
| GETMAIL_OPTS=() | ||
| # If the getmailrc file contains IMAP configuration and the GETMAIL_IDLE variable is set to "auto" or contains the specific getmailrc file, enable IMAP IDLE for this getmailrc file. | ||
| if grep -q 'IMAP' "${RC_FILE}" && [[ ${GETMAIL_IDLE} == "auto" || ${GETMAIL_IDLE} == *$(basename "${RC_FILE}")* ]]; then |
There was a problem hiding this comment.
GETMAIL_IDLE is matched with unquoted substring globs (*$(basename "${RC_FILE}")*), including the inner check on line 124. A value of user4 also matches configs named user, user4-backup, or myuser4, and can attach the wrong --idle= mailbox. Compare the token before : with an exact equality against the rc basename (the .cf stem in /etc/getmailrc.d/).
| local FILE="/var/log/supervisor/${SERVICE}.log" | ||
| # Alternative log location fallback: | ||
| [[ -f ${FILE} ]] || FILE="/var/log/mail/${SERVICE}.log" | ||
| _exec_in_container test -f ${FILE} || FILE="/var/log/mail/${SERVICE}.log" |
There was a problem hiding this comment.
This used to run [[ -f ... ]] on the host, so /var/log/supervisor/${SERVICE}.log was never found and every caller fell back to /var/log/mail/. Checking inside the container makes any supervised program (notably rspamd) prefer an often-empty or stdout-only supervisor log. Getmail’s _log messages do belong in supervisor logs; assert that in getmail.bats (or a dedicated helper) instead of changing this shared helper.
| VARS[FETCHMAIL_POLL]="${FETCHMAIL_POLL:=300}" | ||
| VARS[GETMAIL_POLL]="${GETMAIL_POLL:=5}" | ||
| VARS[GETMAIL_PARALLEL]="${GETMAIL_PARALLEL:=0}" | ||
| VARS[GETMAIL_IDLE]="${GETMAIL_IDLE:=auto}" |
There was a problem hiding this comment.
Defaulting GETMAIL_IDLE to auto means GETMAIL_PARALLEL=1 turns on --idle for every IMAP rc, with no documented off switch (mailserver.env is also not updated). Default it empty/off, and treat auto as an explicit opt-in.
|
|
||
| ##### GETMAIL_IDLE | ||
|
|
||
| - **auto** => `getmail` Specify which getmail configs should be started with the --idle flag. By default it shall look for the folder INBOX. This can be changed by specifying the folder with a colon. If auto is set, it will be enable for ever IMAP config. Default: auto. |
There was a problem hiding this comment.
This describes the selector as account1, and __usage in getmail-service.sh uses getmail-1.rc, but matching uses the config filename without .cf (e.g. user3). Please document that token, and that --idle=FOLDER only watches that folder for notifications — getmail still fetches mailboxes (default INBOX).
| _init_with_defaults | ||
| _common_container_setup 'CUSTOM_SETUP_ARGUMENTS' | ||
|
|
||
| CONTAINER_NAME=${CONTAINER3_NAME} |
There was a problem hiding this comment.
setup_file leaves CONTAINER_NAME set to CONTAINER3_NAME, so the original sequential tests run against the parallel+IDLE container. Export CONTAINER_NAME=${CONTAINER1_NAME} in those tests. The new cases only grep debug log strings; a pgrep --full --idle= check would catch argv mistakes the logs can miss.
Similar to the FETCHMAIL_PARALLEL option which enables the use of IMAP IDLE, this PR provides the same functionality for getmail.
It builds upon the existing code as it doesn't touch the config file generation. Instead it only focusses on the start of getmail.
This should provide the functionality requested in discussion #4667
Type of change
Checklist
docs/)CHANGELOG.md