GutoVeronezi opened a new pull request #5297: URL: https://github.com/apache/cloudstack/pull/5297
### Description This PR solves issue #5124. The main focus of it is to change how volume snapshots are taken in KVM. However, this proposal of changing `take snapshot` workflow in KVM impacts others snapshot workflows as well. The impacted workflows we mapped are: - Take volume snapshot with running vm - Take volume snapshot with stopped vm - Recurring volume snapshot - Create template from snapshot - Create volume from snapshot - Migrate virtual machine with volumes - Migrate volumes - Revert volume snapshot - Delete volume snapshot Issue #5124 has more details and flowcharts of all the mapped workflows. The focus of this PR is to refactor KVM snapshot, others hypervisors workflows should not be affected. ### Types of changes - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [x] Enhancement (improves an existing feature and functionality) - [ ] Cleanup (Code refactoring and cleanup, that may add test cases) ### Feature/Enhancement Scale or Bug Severity #### Feature/Enhancement Scale - [x] Major - [ ] Minor ### How Has This Been Tested? I added unit tests to several methods and tested the workflows: 1. Take volume snapshot with running vm 2. Take volume snapshot with stopped vm 3. Recurring volume snapshot 4. Create template from snapshot 5. Create volume from snapshot 6. Migrate virtual machine with volumes 7. Migrate volumes 8. Revert volume snapshot 9. Delete volume snapshot These workflows were tested twice, once with the global setting `snapshot.backup.to.secondary` as `true` and once as `false`. To test workflows 1, 2, and 3, I created a VM called `Test1`, then I opened its console to create a file, which I called `testfile`. At first, I wrote `gold` in this file and took a snapshot that I called `gold` (this tests workflow 1). Then I wrote `silver` to the file and configured a recurring snapshot. I waited for the recurring snapshot and, when it was took, I changed the name in database to `silver`, to facilitate the steps (this tests workflow 2). Finally, I wrote `copper` to the file and stopped the VM, then I took a snapshot (this tests workflow 3). After that, I destroyed VM `Test1`. To test workflow 4, I created a template from snapshot `silver` and called it `template silver`. From it, I created a VM called `Test2`, then I opened its console and retrieved the content of the `testfile` with the command `cat`. It returned `silver`, which is the same value of the file when I took the snapshot on workflow 2. After that, I stopped VM `Test2`. To test workflow 5, I created a volume from snapshot `gold` and called it `volume gold`, then I changed the root volume of the VM `Test2` to the `volume gold`. I started the VM `Test2` and retrieved the content of the `testfile` with the command `cat`. It returned `gold`, which is the same value of the file when I took the snapshot on workflow 1. To test workflows 6 and 7, I wrote `platinum` to the file `testfile` in VM `Test2`, then I took a snapshot and called it `platinum`. I migrated the VM and the volume to another host and primary storage with the API `migrateVirtualMachineWithVolume`. When the global setting `snapshot.backup.to.secondary` was `true`, it migrated successfully. When it was `false`, an exception was threw, warning user about snapshots on primary storage (this tests workflow 6). I stopped the VM and migrated only the volume to another primary storage. When the global setting `snapshot.backup.to.secondary` was `true`, it migrated successfully. When it was `false`, an exception was threw, warning users about snapshots on primary storagee (this tests workflow 7). To test workflow 8, I started VM `Test2` and wrote `diamond` to the file `testfile`. Then I stopped the VM `Test2` and reverted the volume to the snapshot `platinum`. Then I opened its console and retrieved the content of the `testfile` with the command `cat`. It returned `platinum`, which is the same value of the file when I took the snapshot before the workflow 6. To test workflow 9, I deleted all the snapshots. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
