From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.ebner@proxmox.com>
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 51B30723E0
 for <pve-devel@lists.proxmox.com>; Mon, 12 Apr 2021 13:37:53 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 485B21E28C
 for <pve-devel@lists.proxmox.com>; Mon, 12 Apr 2021 13:37:23 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (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 firstgate.proxmox.com (Proxmox) with ESMTPS id 24B161E268
 for <pve-devel@lists.proxmox.com>; Mon, 12 Apr 2021 13:37:22 +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 DFF8545A06
 for <pve-devel@lists.proxmox.com>; Mon, 12 Apr 2021 13:37:21 +0200 (CEST)
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Mon, 12 Apr 2021 13:37:15 +0200
Message-Id: <20210412113717.25356-1-f.ebner@proxmox.com>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.007 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 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
Subject: [pve-devel] [PATCH storage 1/3] volume export/import: allow
 uppercase letters
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Mon, 12 Apr 2021 11:37:53 -0000

Bug reported in the community forum[0].

Currently, it's possible to break replication by:
1. have an existing snapshot whose name contains an uppercase letter
2. set up a replication job and run it
3. rollback to the existing snapshot
4. replicate again -> fails

The failure occurs, because after step 3, the most recent common snapshot is the
previously existing one and currently no uppercase letters are allowed for
export/import.

The pve-snapshot-name option uses the CONFIGID_RE
    qr/[a-z][a-z0-9_-]+/i
so it cannot be used here, because it would not allow for e.g. '__migrate__'.
Simply allow uppercase letters, to be backwards compatible and allow all
possible pve-snapshot-name values.

There is still an issue if there also was state volume, but that's a different
bug[1].

[0]: https://forum.proxmox.com/threads/solved-migration-error-base-value-does-not-match-the-regex-pattern.85946/
[1]: https://bugzilla.proxmox.com/show_bug.cgi?id=3111

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 PVE/CLI/pvesm.pm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/PVE/CLI/pvesm.pm b/PVE/CLI/pvesm.pm
index 3594774..7b46897 100755
--- a/PVE/CLI/pvesm.pm
+++ b/PVE/CLI/pvesm.pm
@@ -244,14 +244,14 @@ __PACKAGE__->register_method ({
 	    base => {
 		description => "Snapshot to start an incremental stream from",
 		type => 'string',
-		pattern => qr/[a-z0-9_\-]{1,40}/,
+		pattern => qr/[a-z0-9_\-]{1,40}/i,
 		maxLength => 40,
 		optional => 1,
 	    },
 	    snapshot => {
 		description => "Snapshot to export",
 		type => 'string',
-		pattern => qr/[a-z0-9_\-]{1,40}/,
+		pattern => qr/[a-z0-9_\-]{1,40}/i,
 		maxLength => 40,
 		optional => 1,
 	    },
@@ -321,7 +321,7 @@ __PACKAGE__->register_method ({
 	    base => {
 		description => "Base snapshot of an incremental stream",
 		type => 'string',
-		pattern => qr/[a-z0-9_\-]{1,40}/,
+		pattern => qr/[a-z0-9_\-]{1,40}/i,
 		maxLength => 40,
 		optional => 1,
 	    },
@@ -335,7 +335,7 @@ __PACKAGE__->register_method ({
 	    'delete-snapshot' => {
 		description => "A snapshot to delete on success",
 		type => 'string',
-		pattern => qr/[a-z0-9_\-]{1,80}/,
+		pattern => qr/[a-z0-9_\-]{1,80}/i,
 		maxLength => 80,
 		optional => 1,
 	    },
-- 
2.20.1