From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D342F94FA3 for ; Tue, 17 Jan 2023 10:04:01 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AD2BF945F for ; Tue, 17 Jan 2023 10:03:31 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 17 Jan 2023 10:03:30 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B63A5446A2 for ; Tue, 17 Jan 2023 10:03:30 +0100 (CET) Message-ID: Date: Tue, 17 Jan 2023 10:03:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Thunderbird/109.0 Content-Language: en-GB To: Proxmox VE development discussion , Friedrich Weber References: <20230116165234.1460117-1-f.weber@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20230116165234.1460117-1-f.weber@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.038 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [centos.pm] Subject: [pve-devel] applied: [PATCH container] fix #4460: setup: centos: create /etc/hostname if it does not exist X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jan 2023 09:04:01 -0000 Am 16/01/2023 um 17:52 schrieb Friedrich Weber: > Previously, Setup/CentOS.pm only wrote to /etc/hostname if the file Nit: note that we prefer avoiding code file names in favor of module names or more general terms like "the CentOS setup module" - if one wants to know which file got altered they can always check the git diff/show --stat output. There are naturally some commits where it may be warranted, but it's rather an exception. The rest of the commit message and patch was really great, so it's really just an very minor nit. > already existed. Many CT templates of Redhat-derived distros do not > contain that file, so the containers ended up without /etc/hostname. > This caused systemd-hostnamed to report the "static hostname" to be > empty. If networking is handled by NetworkManager, the empty static > hostname caused DHCP requests to be sent without the "Hostname" field, > as reported in #4460. > > With this fix, Setup/CentOS.pm creates /etc/hostname if it does not > exist, so NetworkManager correctly reads the hostname and includes it in > DHCP requests. > > Manually tested with the following CT templates (checking that > /etc/hostname exists and DHCP requests include the hostname): > > * Distros using NetworkManager: > - Alma Linux 9 (almalinux-9-default_20221108_amd64.tar.xz) > - CentOS 8 (centos-8-default_20201210_amd64.tar.xz) > - CentOS 9 Stream (centos-9-stream-default_20221109_amd64.tar.xz) > - Rocky Linux 9 (rockylinux-9-default_20221109_amd64.tar.xz) > * Distros using network-scripts (here, DHCP requests already contained the > hostname without this fix, as network-scripts does not rely on > systemd-hostnamed): > - Alma Linux 8 (almalinux-8-default_20210928_amd64.tar.xz) > - CentOS 7 (centos-7-default_20190926_amd64.tar.xz) > - CentOS 8 Stream (centos-8-stream-default_20220327_amd64.tar.xz) > - Rocky Linux 8 (rockylinux-8-default_20210929_amd64.tar.xz) > > Signed-off-by: Friedrich Weber > --- > > Question: This will cause Setup/CentOS.pm to create /etc/hostname also > in already-existing containers. I don't think this should any cause > issues for users, but I'm not sure. What do you think? first, as long as the central ct_file_set_contents is used any admin/user can control if a file is ignored by creating a ".pve-ignore.$file" in the same directory. When initially introducing this in c0eae40 ("add class for redhat based containers") we can see that the if was accompanied by an else earlier, as it then was deemed to either set the hostname via /etc/hostname or the sysconfig. There's no actual reason for why that's the case, as after all it would always be the same value, so it seems that it couldn't have ever hurt to set both, well, at least if nothing changed behavior significantly depending on the existence of /etc/hostname - which would be IMO really weird and in any case quite hard to find out for all possible CentOS et al. packages - so rather I'd just roll this out slowly and check for regression reports in the support channels. > > src/PVE/LXC/Setup/CentOS.pm | 5 ++--- > src/test/test-centos6-001/etc/hostname.exp | 1 + > src/test/test-centos6-002/etc/hostname.exp | 1 + > src/test/test-centos8-001/etc/hostname.exp | 1 + > 4 files changed, 5 insertions(+), 3 deletions(-) > create mode 100644 src/test/test-centos6-001/etc/hostname.exp > create mode 100644 src/test/test-centos6-002/etc/hostname.exp > create mode 100644 src/test/test-centos8-001/etc/hostname.exp > > applied, thanks!