Add --with-snapshots to vitastor-cli modify --rename #191

Merged
vitalif merged 2 commits from koolkhel/vitastor:cli-rename-snapshots into master 2026-11-27 18:46:47 +03:00
Contributor

Description

Snapshots are separate inodes named <image>@<snap>, tied to their image only by that name. vitastor-cli modify <image> --rename <new> renames the image alone, so its snapshots keep the old name: they no longer show up as the image's snapshots (the OpenStack driver looks them up as <volume>@<snap>), and a new image created under the old name would look like their owner.

This adds --with-snapshots to modify --rename. The default stays as it was. With the option, after the image is renamed, every <old>@* is renamed to <new>@* one by one through the usual single-image rename. The rename is refused before anything changes if any <new>@* already exists. If a snapshot rename fails, the error says that the image is already renamed and names the snapshot that is not.

Found: seen on a test stand: after an image was renamed, its snapshot kept the old name, dropped out of the image's snapshot list and was left behind when the image was deleted.

Tested: new tests/test_modify_image_rename.sh (etcd only). It checks that with --with-snapshots the snapshots, the /index/image keys and parent_name follow the rename. It also checks that the rename is refused with nothing changed when <new>@* exists, and that without the option only the image is renamed. Passes with the change; on master the option is ignored and the first check fails.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description Snapshots are separate inodes named `<image>@<snap>`, tied to their image only by that name. `vitastor-cli modify <image> --rename <new>` renames the image alone, so its snapshots keep the old name: they no longer show up as the image's snapshots (the OpenStack driver looks them up as `<volume>@<snap>`), and a new image created under the old name would look like their owner. This adds `--with-snapshots` to `modify --rename`. The default stays as it was. With the option, after the image is renamed, every `<old>@*` is renamed to `<new>@*` one by one through the usual single-image rename. The rename is refused before anything changes if any `<new>@*` already exists. If a snapshot rename fails, the error says that the image is already renamed and names the snapshot that is not. Found: seen on a test stand: after an image was renamed, its snapshot kept the old name, dropped out of the image's snapshot list and was left behind when the image was deleted. Tested: new `tests/test_modify_image_rename.sh` (etcd only). It checks that with `--with-snapshots` the snapshots, the `/index/image` keys and `parent_name` follow the rename. It also checks that the rename is refused with nothing changed when `<new>@*` exists, and that without the option only the image is renamed. Passes with the change; on master the option is ignored and the first check fails. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-11-25 20:25:30 +03:00
Snapshots are separate inodes named <image>@<snap>, tied to their image
only by that name. `modify --rename` renamed the image alone, so its
snapshots kept the old name: they no longer showed up as the image's
snapshots (the OpenStack driver looks them up as <volume>@<snap>), and a
new image created under the old name would look like their owner.

Rename every <old>@* inode to <new>@* in the same etcd transaction as
the image, and refuse the rename if any <new>@* already exists. As a
side effect, `--rename <same name>` together with another change no
longer fails with "duplicate key given in txn request".
vitalif requested changes 2026-11-25 21:09:39 +03:00
vitalif left a comment
Owner

Ну по дефолту так делать точно не нужно
В крайнем случае можно добавить опцию --with-snapshots или типа того

Ну по дефолту так делать точно не нужно В крайнем случае можно добавить опцию --with-snapshots или типа того
Owner

Кстати транзакционно это делать особо-то и не нужно, их можно последовательно переименовать вполне

Кстати транзакционно это делать особо-то и не нужно, их можно последовательно переименовать вполне
koolkhel added 1 commit 2026-11-25 22:50:05 +03:00
Keep the default rename as it was. With --with-snapshots, rename the
snapshots <name>@* to <new-name>@* one by one after the image, through
the usual single-image rename, instead of in one transaction. Still
refuse the rename if any <new-name>@* already exists.
koolkhel changed title from Rename snapshots together with the image in vitastor-cli modify to Add --with-snapshots to vitastor-cli modify --rename 2026-11-25 22:50:14 +03:00
Author
Contributor

Переделал: по умолчанию всё как было, снимки переименовываются только с --with-snapshots, по одному после образа обычным rename, без общей транзакции.
Отказ, если какой-то <new>@* уже существует, оставил; тест проверяет и опцию, и поведение без неё.

Переделал: по умолчанию всё как было, снимки переименовываются только с `--with-snapshots`, по одному после образа обычным rename, без общей транзакции. Отказ, если какой-то `<new>@*` уже существует, оставил; тест проверяет и опцию, и поведение без неё.
vitalif merged commit 6b103473c5 into master 2026-11-27 18:46:47 +03:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#191
No description provided.