Skip to content

Fix of revert RBD snapshots - #5544

Merged
sureshanaparti merged 7 commits into
apache:4.16from
slavkap:fix_revertsnapshot_not_on_secondary
Feb 10, 2022
Merged

Fix of revert RBD snapshots#5544
sureshanaparti merged 7 commits into
apache:4.16from
slavkap:fix_revertsnapshot_not_on_secondary

Conversation

@slavkap

@slavkap slavkap commented Oct 1, 2021

Copy link
Copy Markdown
Contributor

Description

If a snapshot is taken only on Primary storage with the option "snapshot.backup.to.secondary" disabled, and after this when you enable the option the revert will fail. Added check if there isn't a snapshot on Secondary storage to check for it on Primary.

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)

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

4.15 and main with KVM hypervisors

set snapshot.backup.to.secondary to false
take one or more snapshots
set snapshot.backup.to.secondary to true
try to revert the snapshot. The operation will fail with "snapshot [snapshot ID] does not exists in data store"

@DaanHoogland

Copy link
Copy Markdown
Contributor

@slavkap code looks good, but shouldn't this extra check only occurs if snapshot.backup.to.secondary is set to false?

@slavkap

slavkap commented Oct 2, 2021

Copy link
Copy Markdown
Contributor Author

@DaanHoogland, thanks for the review! If you ask me, the right solution is first to check if the snapshot is on the primary storage and, if it's not there, to check on secondary. From what I saw in all of the storage plugins, the snapshots are kept on primary storage always. For me checking the value of snapshot.backup.to.secondary is just a limitation. I think that this method should be modified or removed:

 private DataStoreRole getDataStoreRole(Snapshot snapshot, SnapshotDataStoreDao snapshotStoreDao, DataStoreManager dataStoreMgr) {
    SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary);

    if (snapshotStore == null) {
        return DataStoreRole.Image;
    }

    long storagePoolId = snapshotStore.getDataStoreId();
    DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);

    Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities();

    if (mapCapabilities != null) {
        String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString());
        Boolean supportsStorageSystemSnapshots = new Boolean(value);

        if (supportsStorageSystemSnapshots) {
            return DataStoreRole.Primary;
        }
    }

    StoragePoolVO storagePoolVO = _storagePoolDao.findById(storagePoolId);
    if (storagePoolVO.getPoolType() == StoragePoolType.RBD && !BackupSnapshotAfterTakingSnapshot.value()) {
        return DataStoreRole.Primary;
    }

    return DataStoreRole.Image;
}

@yadvr

yadvr commented Oct 2, 2021

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

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

@yadvr

yadvr commented Oct 3, 2021

Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@rhtyd 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-2299)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 31238 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5544-t2299-kvm-centos7.zip
Smoke tests completed. 87 look OK, 0 have errors
Only failed tests results shown below:

Test Result Time (s) Test File

@DaanHoogland

Copy link
Copy Markdown
Contributor

@DaanHoogland, thanks for the review! If you ask me, the right solution is first to check if the snapshot is on the primary storage and, if it's not there, to check on secondary. From what I saw in all of the storage plugins, the snapshots are kept on primary storage always. For me checking the value of snapshot.backup.to.secondary is just a limitation. I think that this method should be modified or removed:

 private DataStoreRole getDataStoreRole(Snapshot snapshot, SnapshotDataStoreDao snapshotStoreDao, DataStoreManager dataStoreMgr) {
    SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Primary);

    if (snapshotStore == null) {
        return DataStoreRole.Image;
    }

    long storagePoolId = snapshotStore.getDataStoreId();
    DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);

    Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities();

    if (mapCapabilities != null) {
        String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString());
        Boolean supportsStorageSystemSnapshots = new Boolean(value);

        if (supportsStorageSystemSnapshots) {
            return DataStoreRole.Primary;
        }
    }

    StoragePoolVO storagePoolVO = _storagePoolDao.findById(storagePoolId);
    if (storagePoolVO.getPoolType() == StoragePoolType.RBD && !BackupSnapshotAfterTakingSnapshot.value()) {
        return DataStoreRole.Primary;
    }

    return DataStoreRole.Image;
}

@slavkap , are you doing / planning that? or creating a ticket for it?

@yadvr yadvr added this to the 4.16.0.0 milestone Oct 4, 2021
@yadvr

yadvr commented Oct 5, 2021

Copy link
Copy Markdown
Member

@sureshanaparti @nvazquez @DaanHoogland what's the concensus here, is this good to merge?

@sureshanaparti

Copy link
Copy Markdown
Contributor

@sureshanaparti @nvazquez @DaanHoogland what's the concensus here, is this good to merge?

not yet @rhtyd

@nvazquez nvazquez modified the milestones: 4.16.0.0, 4.16.1.0 Oct 5, 2021
@slavkap
slavkap marked this pull request as draft October 6, 2021 06:12
@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@slavkap

slavkap commented Oct 6, 2021

Copy link
Copy Markdown
Contributor Author

@sureshanaparti, I have to make some changes in the unit tests, that's why I converted it as a draft

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✖️ el7 ✖️ el8 ✖️ debian. SL-JID 1518

@slavkap
slavkap marked this pull request as ready for review October 6, 2021 11:24
@slavkap

slavkap commented Oct 6, 2021

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@slavkap a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@sureshanaparti

Copy link
Copy Markdown
Contributor

@slavkap can you re-target to 'main' pls.

@blueorangutan

Copy link
Copy Markdown

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

@slavkap
slavkap changed the base branch from 4.15 to main October 6, 2021 12:54
@yadvr

yadvr commented Nov 15, 2021

Copy link
Copy Markdown
Member

Hi @slavkap should this be targetted for 4.17 or 4.16.1?

@slavkap

slavkap commented Nov 15, 2021

Copy link
Copy Markdown
Contributor Author

Hi @rhtyd, I guess that it will be better to get in 4.16.1. Later today I'll change the target branch

@yadvr
yadvr changed the base branch from main to 4.16 November 15, 2021 14:04
@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan test centos7 vmware-67u3

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a Trillian-Jenkins test job (centos7 mgmt + vmware-67u3) has been kicked to run smoke tests

@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.

cltgm

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-3230)
Environment: vmware-67u3 (x2), Advanced Networking with Mgmt server 7
Total time taken: 36034 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5544-t3230-vmware-67u3.zip
Smoke tests completed. 92 look OK, 0 have errors
Only failed tests results shown below:

Test Result Time (s) Test File

@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan test keepEnv

@blueorangutan

Copy link
Copy Markdown

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

@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 needs manual testing.

Comment thread server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java Outdated
Comment thread server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java Outdated
@sureshanaparti

Copy link
Copy Markdown
Contributor

Verified snapshot operations with PowerFlex and NFS. Minor suggestions on error messages. rest all LGTM.

If snapshot is taken only on Primary storage with the option "snapshot.backup.to.secondary" set to true, when you set this option to false the revert will fail. Added check if the snapshot is not on Secondary to check for it on Primary
Will check first if the snapshot is on Primary storage, if not will
return Image as data store
@slavkap
slavkap force-pushed the fix_revertsnapshot_not_on_secondary branch from 34568ca to d4e0ecc Compare February 9, 2022 12:17
@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

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

@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan test centos7 xcpng82

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a Trillian-Jenkins test job (centos7 mgmt + xcpng82) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-3267)
Environment: xcpng82 (x2), Advanced Networking with Mgmt server 7
Total time taken: 48294 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5544-t3267-xcpng82.zip
Smoke tests completed. 91 look OK, 1 have errors
Only failed tests results shown below:

Test Result Time (s) Test File
test_08_arping_in_ssvm Failure 5.17 test_diagnostics.py

@sureshanaparti

Copy link
Copy Markdown
Contributor

Trillian test result (tid-3267) Environment: xcpng82 (x2), Advanced Networking with Mgmt server 7 Total time taken: 48294 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5544-t3267-xcpng82.zip Smoke tests completed. 91 look OK, 1 have errors Only failed tests results shown below:

Test Result Time (s) Test File
test_08_arping_in_ssvm Failure 5.17 test_diagnostics.py

test failure ^^^ is unrelated to the PR changes.

@sureshanaparti
sureshanaparti merged commit 4ffb949 into apache:4.16 Feb 10, 2022
Pearl1594 pushed a commit to shapeblue/cloudstack that referenced this pull request Feb 14, 2022
* Fix of revert RBD snapshots

If snapshot is taken only on Primary storage with the option "snapshot.backup.to.secondary" set to true, when you set this option to false the revert will fail. Added check if the snapshot is not on Secondary to check for it on Primary

* Check if snapshot is on primary storage

Will check first if the snapshot is on Primary storage, if not will
return Image as data store

* Fix unit tests

* removed unused method's params

* Formatted error message and added the snapshot ID to it

* Return to the old logic, the fix will only apply to RBD

* Formatted Exception's messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants