Skip to content

[KVM] Fix for Revert volume snapshot#6527

Merged
yadvr merged 3 commits into
apache:4.17from
shapeblue:KVMrevertVolumeSnapshotFix
Jul 20, 2022
Merged

[KVM] Fix for Revert volume snapshot#6527
yadvr merged 3 commits into
apache:4.17from
shapeblue:KVMrevertVolumeSnapshotFix

Conversation

@harikrishna-patnala

@harikrishna-patnala harikrishna-patnala commented Jul 4, 2022

Copy link
Copy Markdown
Member

Description

This PR fixes the issue #6209 where the snapshot revert operation fails after certain volume operations like Migrate VM with volume / migrate volume / reinstall VM.

The root cause of the issue after these volume operations, the primary storage entry is getting deleted for that volume. We have fixed it here to get the primary datastore entry wrt volume and continue the operation.

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)
  • 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

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

  1. Create a VM and stop the VM on a KVM environment
  2. Create snapshot of the volume
  3. migrate VM with volume or volume to a different storage.
  4. Create another snapshot of the same volume
  5. Performed revert operations on these two snapshots and they are successful

@acs-robot

Copy link
Copy Markdown

Found UI changes, kicking a new UI QA build
@blueorangutan ui

@harikrishna-patnala
harikrishna-patnala force-pushed the KVMrevertVolumeSnapshotFix branch from c8b6fd2 to ae7693f Compare July 4, 2022 10:44
@blueorangutan

Copy link
Copy Markdown

@acs-robot a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

@harikrishna-patnala

Copy link
Copy Markdown
Member Author

@blueorangutan package

@acs-robot

Copy link
Copy Markdown

Found UI changes, kicking a new UI QA build
@blueorangutan ui

@blueorangutan

Copy link
Copy Markdown

@acs-robot a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

@harikrishna-patnala

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@harikrishna-patnala a Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 3706

@harikrishna-patnala

Copy link
Copy Markdown
Member Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@harikrishna-patnala a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

UI build: ✔️
Live QA URL: http://qa.cloudstack.cloud:8080/client/pr/6527 (SL-JID-1903)

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm

@acs-robot

Copy link
Copy Markdown

Found UI changes, kicking a new UI QA build
@blueorangutan ui

@blueorangutan

Copy link
Copy Markdown

@acs-robot a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

UI build: ✔️
Live QA URL: http://qa.cloudstack.cloud:8080/client/pr/6527 (SL-JID-1905)

@harikrishna-patnala

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@harikrishna-patnala a Jenkins job has been kicked to build packages. It will be bundled with

SystemVM template(s). I'll keep you posted as I make progress.

@sonarqubecloud

sonarqubecloud Bot commented Jul 5, 2022

Copy link
Copy Markdown

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 3710

@harikrishna-patnala

Copy link
Copy Markdown
Member Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@harikrishna-patnala a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-4427)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 36996 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6527-t4427-kvm-centos7.zip
Smoke tests completed. 98 look OK, 0 have errors
Only failed tests results shown below:

Test Result Time (s) Test File

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-4429)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 36972 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6527-t4429-kvm-centos7.zip
Smoke tests completed. 98 look OK, 0 have errors
Only failed tests results shown below:

Test Result Time (s) Test File

throw new CloudRuntimeException("Cannot find an entry for snapshot " + snapshot.getId() + " on primary storage pools");
s_logger.warn("Cannot find an entry for snapshot " + snapshot.getId() + " on primary storage pools, searching with volume's primary storage pool");
VolumeInfo volumeInfo = volFactory.getVolume(snapshot.getVolumeId(), DataStoreRole.Primary);
store = (PrimaryDataStore)volumeInfo.getDataStore();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harikrishna-patnala should we check for subsequent cases where it's not found again or this is null?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not looking for snapshotOnPrimaryStore again. We are just trying to get the appropriate datastore driver to run the command. We are using volume's info here if snapshot on primary os not found. So need to check again.

if (Files.exists(Paths.get(snapshotPath))) {
return new Pair<>(snapshotPath, snapshotOnPrimaryStorage);
KVMStoragePool kvmStoragePoolPrimary, KVMStoragePool kvmStoragePoolSecondary) {
String snapshotPath = null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If snapshotOnPrimaryStorage is null, then this is never set?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to set or use it. If the snapshot on primary is not there then we will get it from secondary storage.

public void revertSnapshot(SnapshotInfo snapshot, SnapshotInfo snapshotOnPrimaryStore, AsyncCompletionCallback<CommandResult> callback) {
RevertSnapshotCommand cmd = new RevertSnapshotCommand((SnapshotObjectTO)snapshot.getTO(), (SnapshotObjectTO)snapshotOnPrimaryStore.getTO());
SnapshotObjectTO dataOnPrimaryStorage = null;
if (snapshotOnPrimaryStore != null) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above if snapshotOnPrimaryStore is null then dataOnPrimaryStorage is never set? (or is it that this will never be null?)

@harikrishna-patnala harikrishna-patnala Jul 6, 2022

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be null. We are handling the same case where snapshotOnPrimary is null.
Following is the complete flow

  1. Look for snapshotOnPrimary entry if exists
  2. If exists, use that entry to find the appropriate driver to execute revertSnapshotCommand
  3. If not found, use volume information to find the appropriate driver to execute revertSnapshotCommand
  4. While executing the revertSnapshotCommand, if snapshotOnPrimary exists, use it to revert the volume
  5. If snapshotOnPrimary does not exists, use the snapshot from secondary storage to revert the volume

@yadvr yadvr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but left some comments. @harikrishna-patnala can you advise how this was tested, is there an existing smoketest or was it manually tested?

@harikrishna-patnala

Copy link
Copy Markdown
Member Author

LGTM but left some comments. @harikrishna-patnala can you advise how this was tested, is there an existing smoketest or was it manually tested?

For revert volume to snapshot I did not see any smoke tests, I've tested it manually and added the steps that I've tested in the description.

  1. Create a VM and stop the VM on a KVM environment
  2. Create snapshot of the volume
  3. migrate VM with volume or volume to a different storage.
  4. Create another snapshot of the same volume
  5. Performed revert operations on these two snapshots and they are successful

To write tests to address the revert operation and the issue here, we have to write the exact same flow as above.

@harikrishna-patnala

Copy link
Copy Markdown
Member Author

@nvazquez @Pearl1594 will you be able to help me test this PR please.

@Pearl1594 Pearl1594 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM

@Pearl1594 Pearl1594 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested fix. LGTM - Was able to revert to snapshot taken before migration of volume.

@yadvr
yadvr changed the base branch from main to 4.17 July 20, 2022 06:03
@yadvr
yadvr merged commit 2c05b63 into apache:4.17 Jul 20, 2022
@yadvr
yadvr deleted the KVMrevertVolumeSnapshotFix branch July 20, 2022 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants