Unclear rules for VM snapshot names

Nick Brown

Active Member
Oct 17, 2016
5
0
41
45
Hi.

I've just installed 4.3, and am liking the new UI.

Short version: I just ran into an issue where I couldn't create a snapshot of a VM, because the snapshot name I tried to use was invalid, but the feedback from the UI didn't me give any clue as to why it was invalid.

Long version: I installed 4.3 onto a pair of disks with ZFS raid1. I have a backup of a VM I created in an earlier release of PVE, and I restored this into the "local-zfs" storage. I booted the VM, and verified it worked ok, then I shut it down and attempted to snapshot it.

(For many years, I've been using ZFS to store VM images (on hypervisors other than PVE), and when I create ZFS snapshots from the CLI, I tend to name them things like: 001_initial-install, 002_pre-upgrade, etc. These are valid ZFS snapshot names.)

When I click the "Take Snapshot" button in the web UI, and type in my intended snapshot name (which was "001_v226-as-restored"), the name box turns red, and I get a mouse-over box which says: "Allowed characters: 'A-Z', 'a-z', '0-9', '_'".

Ok. So it's telling me I can't use a dash, but I can use an underscore. So I change the dashes to underscores, and try again. Still the same validation error. But now I know I'm only using the characters I'm supposed to use.

So I try something else: let's just call the snapshot "x", but I still get the same validation error, and now I'm thinking, WTF? How can x not be in the character range a-z?

So I go digging into the javascript, to find out what validation rule I'm failing on, and it turns out to be this regex:
/^[a-z][a-z0-9\_]+$/i
So there's a couple of consequences to this regex that the validation message in the UI wasn't explaining:
  1. Snapshot names must be at least 2 characters long.
  2. The first character must be a letter.
Regarding point 1, it turns out that the validation code does already explicitly check that the snapshot name satisfies a minimum length, with this code in ext-all.js:
(!c && l.length < g.minLength)​
but the minLength it tests for is zero, so there's a missed opportunity to provide better feedback there.

Hopefully the validation messages can be improved, so other people won't get as confused as I just did.o_O

Cheers,
Nick
 
Hi.

I've just installed 4.3, and am liking the new UI.

Short version: I just ran into an issue where I couldn't create a snapshot of a VM, because the snapshot name I tried to use was invalid, but the feedback from the UI didn't me give any clue as to why it was invalid.

Long version: I installed 4.3 onto a pair of disks with ZFS raid1. I have a backup of a VM I created in an earlier release of PVE, and I restored this into the "local-zfs" storage. I booted the VM, and verified it worked ok, then I shut it down and attempted to snapshot it.

(For many years, I've been using ZFS to store VM images (on hypervisors other than PVE), and when I create ZFS snapshots from the CLI, I tend to name them things like: 001_initial-install, 002_pre-upgrade, etc. These are valid ZFS snapshot names.)

When I click the "Take Snapshot" button in the web UI, and type in my intended snapshot name (which was "001_v226-as-restored"), the name box turns red, and I get a mouse-over box which says: "Allowed characters: 'A-Z', 'a-z', '0-9', '_'".

Ok. So it's telling me I can't use a dash, but I can use an underscore. So I change the dashes to underscores, and try again. Still the same validation error. But now I know I'm only using the characters I'm supposed to use.

So I try something else: let's just call the snapshot "x", but I still get the same validation error, and now I'm thinking, WTF? How can x not be in the character range a-z?

So I go digging into the javascript, to find out what validation rule I'm failing on, and it turns out to be this regex:
/^[a-z][a-z0-9\_]+$/i
So there's a couple of consequences to this regex that the validation message in the UI wasn't explaining:
  1. Snapshot names must be at least 2 characters long.
  2. The first character must be a letter.
Regarding point 1, it turns out that the validation code does already explicitly check that the snapshot name satisfies a minimum length, with this code in ext-all.js:
(!c && l.length < g.minLength)​
but the minLength it tests for is zero, so there's a missed opportunity to provide better feedback there.

Hopefully the validation messages can be improved, so other people won't get as confused as I just did.o_O

Cheers,
Nick

could you file a bug at buzilla.proxmox.com for this? makes tracking easier.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!