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 121D582544 for ; Mon, 29 Nov 2021 11:19:30 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 05B6E2E5D7 for ; Mon, 29 Nov 2021 11:19:00 +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 id 1CEEC2E5CC for ; Mon, 29 Nov 2021 11:18:59 +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 E65D8446B6 for ; Mon, 29 Nov 2021 11:18:58 +0100 (CET) Date: Mon, 29 Nov 2021 11:18:51 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20211126105232.436044-1-f.ebner@proxmox.com> <20211126105232.436044-2-f.ebner@proxmox.com> In-Reply-To: <20211126105232.436044-2-f.ebner@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1638181115.2n67xqu2tx.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.254 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 Subject: [pve-devel] applied-series: [PATCH guest-common 2/2] replication: prepare: simplify code 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: Mon, 29 Nov 2021 10:19:30 -0000 On November 26, 2021 11:52 am, Fabian Ebner wrote: > No functional change is intended. >=20 > Signed-off-by: Fabian Ebner > --- > src/PVE/Replication.pm | 46 +++++++++++++++++++----------------------- > 1 file changed, 21 insertions(+), 25 deletions(-) >=20 > diff --git a/src/PVE/Replication.pm b/src/PVE/Replication.pm > index de652f2..31cabec 100644 > --- a/src/PVE/Replication.pm > +++ b/src/PVE/Replication.pm > @@ -176,32 +176,28 @@ sub prepare { > foreach my $volid (@$volids) { > my $info =3D PVE::Storage::volume_snapshot_info($storecfg, $volid); > for my $snap (keys $info->%*) { > - if ((defined($snapname) && ($snap eq $snapname)) || > - (defined($parent_snapname) && ($snap eq $parent_snapname))) { > - $last_snapshots->{$volid}->{$snap} =3D $info->{$snap}; > - } elsif ($snap =3D~ m/^\Q$prefix\E/) { > - if ($last_sync !=3D 0) { > - $logfunc->("delete stale replication snapshot '$snap' on $volid"); > - eval { > - PVE::Storage::volume_snapshot_delete($storecfg, $volid, $snap); > - $cleaned_replicated_volumes->{$volid} =3D 1; > - }; > - > - # If deleting the snapshot fails, we can not be sure if it was due= to an error or a timeout. > - # The likelihood that the delete has worked out is high at a timeo= ut. > - # If it really fails, it will try to remove on the next run. > - if (my $err =3D $@) { > - # warn is for syslog/journal. > - warn $err; > - > - # logfunc will written in replication log. > - $logfunc->("delete stale replication snapshot error: $err"); > - } =09 > - # Last_sync=3D0 and a replication snapshot only occur, if the VM was s= tolen > - } else { > - $last_snapshots->{$volid}->{$snap} =3D $info->{$snap}; > + if ( # check if it's a stale replication snapshot > + !(defined($snapname) && $snap eq $snapname) && > + !(defined($parent_snapname) && $snap eq $parent_snapname) && > + $snap =3D~ m/^\Q$prefix\E/ && > + $last_sync !=3D 0 # last_sync is 0 if the VM was stolen > + ) { > + $logfunc->("delete stale replication snapshot '$snap' on $volid"); > + eval { > + PVE::Storage::volume_snapshot_delete($storecfg, $volid, $snap); > + $cleaned_replicated_volumes->{$volid} =3D 1; > + }; > + > + # If deleting the snapshot fails, we can not be sure if it was due to = an error or a timeout. > + # The likelihood that the delete has worked out is high at a timeout. > + # If it really fails, it will try to remove on the next run. > + if (my $err =3D $@) { > + # warn is for syslog/journal. > + warn $err; > + > + # logfunc will written in replication log. > + $logfunc->("delete stale replication snapshot error: $err"); > } > - # Other snapshots might need to serve as replication base after rol= lback > } else { > $last_snapshots->{$volid}->{$snap} =3D $info->{$snap}; > } > --=20 > 2.30.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20