[pmg-devel] [PATCH pmg-api/package-rebuilds v3] improve fetchmail handling in PMG

Max R. Carrara m.carrara at proxmox.com
Mon Sep 29 15:26:36 CEST 2025


On Fri Sep 26, 2025 at 9:27 PM CEST, Stoiko Ivanov wrote:
> supersedes: https://lore.proxmox.com/pmg-devel/DD2PXG51NFKF.2D5G45FY3K66F@proxmox.com/T/#t
>
> v2->v3:
> * incoroporated parts of Max' feedback - thanks for the effort and looking
>   at the details!
> * The package-rebuild patches are needed for fetchmail (or rather our
>   integration to work - so they fix a currently broken behavior)
> * For pmg-api I amended the comment in the templated and added a patch,
>   that restarts fetchmail on relevant config-changes.
>
> Added Max' R-b/T-b tags only to patch 1 for pmg-api, and patch 2 for
> package-rebuilds as those remain unchanged (save for a typo in the
> commit message of package-rebuilds)
>
> [...]

Gave this series another spin on my two-node PMG test cluster.

The tl;dr is: Everything appears to work as advertised. Nice job!

package-rebuilds (Patches #1 and #2):

- Even though those two patches were applied already, I've also applied
  them locally, then built and installed the `fetchmail` package

- On the non-master node, the `/etc/default/fetchmail` file
  didn't exist yet; upon installing the package, it appeared again

- On the master node, the `/etc/default/fetchmail` file existed already
  because I created it manually before; upon installing the package, it
  wasn't changed and remained the same (as expected)

pmg-api (Patches #3-5):

- Patch #3 remains unchanged, but for completeness's sake, I also tested
  it again
  - `fetchmail` was able to connect to our mail server with my
    credentials + SSL enabled; works as advertised

- The comment in patch #4 now looks nicer, thanks for incorporating that
  little bit of feedback!

- Patch #5 also works as advertised
  - Created a bunch of dummy accounts via the GUI
  - `fetchmail.service` continued to work as expected, despite the
    restarts
  - I wasn't able to trip `fetchmail.service` up through the GUI, so I
    think that users that create / write / delete a lot of fetchmail
    accounts should also be fine here

To elaborate more on patch #5, since I didn't get fetchmail to trip up,
I think it's perfectly fine to simply restart the service like that.
However, for future reference, if frequent restarts become a problem for
some reason, we can add a call to `sleep` in the `fetchmail.service` unit.

In particular, this would have to be done in `ExecStart=`, as any other
options (that I've tested) cause `systemctl restart` to hang. The
startup delay could be added in a crude way like this:

ExecStart=/usr/bin/bash -c "/usr/bin/sleep 60 && /usr/bin/fetchmail --daemon 300 $OPTIONS --nodetach -f /etc/fetchmailrc --pidfile /run/fetchmail/fetchmail.pid"

During frequent restarts, systemd will terminate the `sleep 60`
(gracefully) if fetchmail itself wasn't yet running; then, the delay
starts again.

Note that I'm not sure if `$OPTIONS` is substituted correctly here; I
only tested the bare minimum there. The best solution—should it actually
be necessary in the future—would probably be to supply a wrapper script
that contains the call to sleep and also passes `$OPTIONS` along to
fetchmail.

Anyway, with all of that aside: LGTM!

Consider:

Tested-by: Max R. Carrara <m.carrara at proxmox.com>
Reviewed-by: Max R. Carrara <m.carrara at proxmox.com>




More information about the pmg-devel mailing list