From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id A1F6E1FF0B4 for ; Tue, 10 Nov 2026 10:28:58 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 11C8D214BE; Tue, 10 Nov 2026 10:28:54 +0100 (CET) Message-ID: Date: Tue, 10 Nov 2026 10:28:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH pve-manager] api: nodes: dns: restart postfix after changing name servers To: Dominik Csapak , pve-devel@lists.proxmox.com References: <20261109105127.96814-1-j.theisen@proxmox.com> Content-Language: en-US From: Jonas Theisen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794302928380 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.097 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: RFJ44WYOM232CF2VJXG5YLPE64PXK2S3 X-Message-ID-Hash: RFJ44WYOM232CF2VJXG5YLPE64PXK2S3 X-MailFrom: j.theisen@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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: >> >> --- 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; >>       }, >>   }); >