Reject creating a snapshot with a duplicate name for the same volume - #14089
Open
nagaboinaramgopal wants to merge 1 commit into
Open
Reject creating a snapshot with a duplicate name for the same volume#14089nagaboinaramgopal wants to merge 1 commit into
nagaboinaramgopal wants to merge 1 commit into
Conversation
Two snapshots of the same volume with the same name map to the same file on the snapshot store, so creating the second overwrites the first, and later deleting either one removes the shared file and leaves the other snapshot pointing at nothing. Reject creating a snapshot when an active (non-destroyed) snapshot with the same name already exists for the volume. Auto-generated names already carry a timestamp so they are unaffected. Fixes: apache#13051
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
CloudStack lets you create more than one snapshot of the same volume with the same name. Since a snapshot's name is used to build its file name on the store, two snapshots of a volume with the same name map to the same file. Creating the second overwrites the first, and later deleting either one removes the shared file and leaves the other snapshot record pointing at a file that no longer exists.
This rejects creating a snapshot when an active (non-destroyed) snapshot with the same name already exists for the volume. Auto-generated snapshot names already include a timestamp, so they are not affected.
Fixes: #13051
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
N/A
How Has This Been Tested?
Added a unit test that creates a snapshot with a name that already exists for the volume and checks it is rejected with an InvalidParameterValueException. Before this change that test fails because the create proceeds; after it, it is rejected. The existing snapshot manager tests still pass.
Also verified on a live 4.23 environment: before the change, two snapshots of the same volume with the same name both complete and end up BackedUp; after it, the second same-name snapshot is rejected while a differently named snapshot on the same volume still completes.
How did you try to break this feature and the system with this change?
The check only compares against active snapshots (not Destroyed or Error), so re-using the name of a deleted snapshot still works. Auto-generated names carry a timestamp, so scheduled and default-named snapshots are not blocked.