From: Jonas Theisen <j.theisen@proxmox.com>
To: Dominik Csapak <d.csapak@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 10:28:48 +0100 [thread overview]
Message-ID: <faac693c-76a9-4f86-a214-9add6be6f3aa@proxmox.com> (raw)
In-Reply-To: <e2528101-4fd9-4984-b05e-060b5b9cd989@proxmox.com>
On 11/10/26 09:32, Dominik Csapak wrote:
> Hi,
>
> first, does postfix really need a restart or would a 'reload' be enough?
Tried that but no a reload does not seem to rewrite the copied config.
Only a restart refreshed the settings.
>
> if so, would it be possible to use try-reload-or-restart instead?
Thanks for that pointer. tbh i wasn't even aware that these existed
with the try prefix. Switched that out for a try-restart, since the
try-reload-or-restart would just issue a reload since postfix is capable
of it.
>
> some comments inline:
>
> On 11/9/26 11:51 AM, Jonas Theisen wrote:
>> <snip>
>> --- 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
Ack switched that out.
>> + ['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?
Right, sorry for whatever reason i tried this on a PVE 8 and
from there to PVE 9 the units changed.
Fixed that in v2.
>
> 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 ;) )
Ack will keep that in mind for the future.
With the current v2 this is not an issue anymore.
>
>> + 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 9:28 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
2026-11-10 9:28 ` Jonas Theisen [this message]
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=faac693c-76a9-4f86-a214-9add6be6f3aa@proxmox.com \
--to=j.theisen@proxmox.com \
--cc=d.csapak@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