From: Dominik Csapak <d.csapak@proxmox.com>
To: Jonas Theisen <j.theisen@proxmox.com>, pve-devel@lists.proxmox.com
Subject: Re: [PATCH pve-manager] api: nodes: dns: restart postfix after changing name servers
Date: Tue, 10 Nov 2026 09:31:47 +0100 [thread overview]
Message-ID: <e2528101-4fd9-4984-b05e-060b5b9cd989@proxmox.com> (raw)
In-Reply-To: <20261109105127.96814-1-j.theisen@proxmox.com>
Hi,
first, does postfix really need a restart or would a 'reload' be enough?
if so, would it be possible to use try-reload-or-restart instead?
some comments inline:
On 11/9/26 11:51 AM, Jonas Theisen wrote:
> Postfix runs its SMTP client in a chroot and copies /etc/resolv.conf
> into it only when the instance starts. A running postfix therefore
> keeps using the old name servers after a DNS settings change,
> which can make mail delivery fail until the next restart.
>
> Restart the postfix service after writing the new settings, but only
> if it is currently active.
> A failed restart only warns, since the DNS settings were already
> written.
>
> Came up in: https://forum.proxmox.com/threads/187442
>
> Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
> ---
> PVE/API2/Nodes.pm | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
> index df0b2c2d..35078d3b 100644
> --- a/PVE/API2/Nodes.pm
> +++ b/PVE/API2/Nodes.pm
> @@ -1671,6 +1671,17 @@ __PACKAGE__->register_method({
>
> PVE::INotify::update_file('resolvconf', $param);
>
> + # postfix copies resolv.conf into its chroot only on start, so a running instance needs a
> + # restart to use the new name servers
> + eval {
> + my $active = PVE::Tools::run_command(
please use `PVE::Cmd::run` for new code instead of `run_command`
(we recently moved that code into it's own perl module)
interface is identical
> + ['systemctl', 'is-active', '--quiet', 'postfix@-'],
> + noerr => 1,
> + );
on several machines of mine this does return an error:
```
root@pve:~# systemctl is-active --quiet postfix@-
root@pve:~# echo $?
3
```
sure it's the right unit to check and restart?
also, '$active' sounds like must be set to >0 if the unit is active
and code below looks like we restart it if it's not running
better name could be
$is_active_error
(or something like that, i'm not the best at naming either ;) )
> + PVE::Tools::run_command(['systemctl', 'restart', 'postfix@-']) if $active == 0;
> + };
> + warn "failed to restart postfix - $@" if $@;
> +
> return;
> },
> });
next prev parent reply other threads:[~2026-11-10 8:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 10:51 [PATCH pve-manager] api: nodes: dns: restart postfix after changing name servers Jonas Theisen
2026-11-10 8:31 ` Dominik Csapak [this message]
2026-11-10 9:28 ` Jonas Theisen
2026-11-10 9:32 ` Jonas Theisen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e2528101-4fd9-4984-b05e-060b5b9cd989@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=j.theisen@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox