From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id AF2DD1FF16F for ; Thu, 19 Dec 2024 17:07:06 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9FB6BC31B; Thu, 19 Dec 2024 17:07:06 +0100 (CET) From: Daniel Kral To: f.gruenbichler@proxmox.com Date: Thu, 19 Dec 2024 17:06:28 +0100 Message-Id: <20241219160628.185966-1-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20240416122054.733817-12-f.gruenbichler@proxmox.com> References: <20240416122054.733817-12-f.gruenbichler@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.004 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 Subject: Re: [pve-devel] [PATCH v2 manager 2/4] pvestatd: collect and broadcast pool usage 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: , Reply-To: Proxmox VE development discussion Cc: pve-devel@lists.proxmox.com Content-Type: multipart/mixed; boundary="===============7660255345602986663==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" --===============7660255345602986663== Content-Transfer-Encoding: quoted-printable This could only be partially applied because of changes to=0D `update_{qemu,lxc}_status` in the mean time:=0D =0D Patch failed at 0002 pvestatd: collect and broadcast pool usage=0D patching file PVE/Service/pvestatd.pm=0D Hunk #1 FAILED at 231.=0D Hunk #2 succeeded at 245 (offset 3 lines).=0D Hunk #3 succeeded at 283 with fuzz 1 (offset 5 lines).=0D Hunk #4 FAILED at 466.=0D Hunk #5 succeeded at 480 (offset 5 lines).=0D Hunk #6 succeeded at 592 with fuzz 1 (offset 11 lines).=0D Hunk #7 FAILED at 593.=0D =0D Inlined the changes to resolve conflicts when applying onto ead665d5=0D ("ui: ceph pool: add columns for application").=0D =0D On 16/04/2024 14:20, Fabian Gr=C3=BCnbichler wrote:=0D > so that other nodes can query it and both block changes that would violat= e the=0D > limits, and mark pools which are violating it currently accordingly.=0D > =0D > Signed-off-by: Fabian Gr=C3=BCnbichler =0D > ---=0D > PVE/Service/pvestatd.pm | 59 ++++++++++++++++++++++++++++++++++++++---=0D > 1 file changed, 55 insertions(+), 4 deletions(-)=0D > =0D > diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm=0D > index 2515120c6..d7e4755e9 100755=0D > --- a/PVE/Service/pvestatd.pm=0D > +++ b/PVE/Service/pvestatd.pm=0D > @@ -231,7 +231,7 @@ sub auto_balloning {=0D > }=0D > =0D > sub update_qemu_status {=0D > - my ($status_cfg) =3D @_;=0D > + my ($status_cfg, $pool_membership, $pool_usage) =3D @_;=0D =0D This should be=0D =0D ```=0D - my ($status_cfg, $pull_txn) =3D @_;=0D + my ($status_cfg, $pull_txn, $pool_membership, $pool_usage) =3D @_;=0D ```=0D =0D as of ead665d5 ("ui: ceph pool: add columns for application").=0D =0D > =0D > my $ctime =3D time();=0D > my $vmstatus =3D PVE::QemuServer::vmstatus(undef, 1);=0D > @@ -242,6 +242,21 @@ sub update_qemu_status {=0D > my $transactions =3D PVE::ExtMetric::transactions_start($status_cfg)= ;=0D > foreach my $vmid (keys %$vmstatus) {=0D > my $d =3D $vmstatus->{$vmid};=0D > +=0D > + if (my $pool =3D $pool_membership->{$vmid}) {=0D > + $pool_usage->{$pool}->{$vmid} =3D {=0D > + cpu =3D> {=0D > + config =3D> ($d->{confcpus} // 0),=0D > + run =3D> ($d->{runcpus} // 0),=0D > + },=0D > + mem =3D> {=0D > + config =3D> ($d->{confmem} // 0),=0D > + run =3D> ($d->{runmem} // 0),=0D > + },=0D > + running =3D> $d->{pid} ? 1 : 0,=0D > + };=0D > + }=0D > +=0D > my $data;=0D > my $status =3D $d->{qmpstatus} || $d->{status} || 'stopped';=0D > my $template =3D $d->{template} ? $d->{template} : "0";=0D > @@ -263,6 +278,17 @@ sub update_qemu_status {=0D > PVE::ExtMetric::transactions_finish($transactions);=0D > }=0D > =0D > +sub update_pool_usage {=0D > + my ($usage) =3D @_;=0D > +=0D > + my $ctime =3D time();=0D > +=0D > + # TODO? RRD and ExtMetric support here?=0D > +=0D > + my $new =3D { data =3D> $usage, timestamp =3D> $ctime };=0D > + PVE::Cluster::broadcast_node_kv('pool-usage', encode_json($new));=0D > +}=0D > +=0D > sub remove_stale_lxc_consoles {=0D > =0D > my $vmstatus =3D PVE::LXC::vmstatus();=0D > @@ -440,7 +466,7 @@ sub rebalance_lxc_containers {=0D > }=0D > =0D > sub update_lxc_status {=0D > - my ($status_cfg) =3D @_;=0D > + my ($status_cfg, $pool_membership, $pool_usage) =3D @_;=0D =0D This should be=0D =0D ```=0D - my ($status_cfg, $pull_txn) =3D @_;=0D + my ($status_cfg, $pull_txn, $pool_membership, $pool_usage) =3D @_;=0D ```=0D =0D > =0D > my $ctime =3D time();=0D > my $vmstatus =3D PVE::LXC::vmstatus();=0D > @@ -449,6 +475,21 @@ sub update_lxc_status {=0D > =0D > foreach my $vmid (keys %$vmstatus) {=0D > my $d =3D $vmstatus->{$vmid};=0D > +=0D > + if (my $pool =3D $pool_membership->{$vmid}) {=0D > + $pool_usage->{$pool}->{$vmid} =3D {=0D > + cpu =3D> {=0D > + config =3D> ($d->{confcpus} // 0),=0D > + run =3D> ($d->{runcpus} // 0),=0D > + },=0D > + mem =3D> {=0D > + config =3D> ($d->{confmem} // 0),=0D > + run =3D> ($d->{runmem} // 0),=0D > + },=0D > + running =3D> $d->{status} eq 'running' ? 1 : 0,=0D > + };=0D > + }=0D > +=0D > my $template =3D $d->{template} ? $d->{template} : "0";=0D > my $data;=0D > if ($d->{status} eq 'running') { # running=0D > @@ -540,6 +581,10 @@ sub update_status {=0D > syslog('err', $err) if $err;=0D > =0D > my $status_cfg =3D PVE::Cluster::cfs_read_file('status.cfg');=0D > + my $user_cfg =3D PVE::Cluster::cfs_read_file('user.cfg');=0D > + my $pools =3D $user_cfg->{pools};=0D > + my $pool_membership =3D $user_cfg->{vms};=0D > + my $pool_usage =3D {};=0D > =0D > eval {=0D > update_node_status($status_cfg);=0D > @@ -548,17 +593,23 @@ sub update_status {=0D > syslog('err', "node status update error: $err") if $err;=0D > =0D > eval {=0D > - update_qemu_status($status_cfg);=0D > + update_qemu_status($status_cfg, $pool_membership, $pool_usage);=0D =0D This should be=0D =0D ```=0D - update_qemu_status($status_cfg, $pull_txn);=0D + update_qemu_status($status_cfg, $pull_txn, $pool_membership, $pool_= usage);=0D ```=0D =0D > };=0D > $err =3D $@;=0D > syslog('err', "qemu status update error: $err") if $err;=0D > =0D > eval {=0D > - update_lxc_status($status_cfg);=0D > + update_lxc_status($status_cfg, $pool_membership, $pool_usage);=0D =0D ```=0D - update_lxc_status($status_cfg, $pull_txn);=0D + update_lxc_status($status_cfg, $pull_txn, $pool_membership, $pool_u= sage);=0D ```=0D =0D > };=0D > $err =3D $@;=0D > syslog('err', "lxc status update error: $err") if $err;=0D > =0D > + eval {=0D > + update_pool_usage($pool_usage);=0D > + };=0D > + $err =3D$@;=0D =0D nit: missing whitespace between `=3D` and `$@`.=0D =0D > + syslog('err', "pool usage status update error: $err") if $err;=0D > +=0D > eval {=0D > rebalance_lxc_containers();=0D > };=0D > -- =0D > 2.39.2=0D =0D =0D =0D =0D =0D --===============7660255345602986663== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel --===============7660255345602986663==--