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 C25EF73944 for ; Fri, 18 Jun 2021 16:52:47 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B0AF19FD8 for ; Fri, 18 Jun 2021 16:52:17 +0200 (CEST) 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 id C5A2D9FCA for ; Fri, 18 Jun 2021 16:52:16 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9A97444214 for ; Fri, 18 Jun 2021 16:52:16 +0200 (CEST) Message-ID: Date: Fri, 18 Jun 2021 16:52:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Thunderbird/90.0 Content-Language: en-US To: Proxmox VE development discussion , Lorenz Stechauner References: <20210618133423.4014934-1-l.stechauner@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20210618133423.4014934-1-l.stechauner@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.810 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. [pve6to7.pm] Subject: [pve-devel] applied: [PATCH v2 manager] pve6to7: add check for guest and node description length 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: Fri, 18 Jun 2021 14:52:47 -0000 On 18.06.21 15:34, Lorenz Stechauner wrote: > Signed-off-by: Lorenz Stechauner > --- > changes to v1: > * using ::config_list() instead of ::vmstatus() > > PVE/CLI/pve6to7.pm | 37 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 37 insertions(+) > > diff --git a/PVE/CLI/pve6to7.pm b/PVE/CLI/pve6to7.pm > index fc779e4f..f9433028 100644 > --- a/PVE/CLI/pve6to7.pm > +++ b/PVE/CLI/pve6to7.pm > @@ -15,9 +15,11 @@ use PVE::Cluster; > use PVE::Corosync; > use PVE::INotify; > use PVE::JSONSchema; > +use PVE::NodeConfig; > use PVE::RPCEnvironment; > use PVE::Storage; > use PVE::Tools qw(run_command split_list); > +use PVE::QemuConfig; > use PVE::QemuServer; > use PVE::VZDump::Common; > > @@ -660,6 +662,40 @@ sub check_custom_pool_roles { > } > } > > +sub check_description_lengths { > + log_info("Checking node and guest description/note legnth.."); > + > + my $nodes = PVE::Cluster::get_nodelist();; > + foreach my $node (@$nodes) { > + my $conf = PVE::NodeConfig::load_config($node); > + my $desc = $conf->{description}; > + next if !defined($desc); > + if (length($desc) > 64 * 1024) { > + log_warn("Description of node $node is too long! - maximum will be 64k"); > + } First I'd have recommend factoring above out in a helper, as it's repeated very similarly below another two times. my sub check_max_length { my ($raw, $max_length, $warning) = @_; log_warn($warning) if defined($raw) && length($raw) > $max_length; } check_max_length($conf->{description}, 64 * 1024, "description in config of node $node is too long! maximum will be 64k"); but I felt that joining all guests and all nodes each into a single warn was nicer, so I reworked it a bit to first push all to an array and then output them joined, not the nicest code but slightly shorter and the output looks good, IMO at least..