Skip to content

Create new Instance from VM backup - #10140

Merged
sureshanaparti merged 188 commits into
apache:mainfrom
shapeblue:instance-from-backup
Jul 31, 2025
Merged

Create new Instance from VM backup#10140
sureshanaparti merged 188 commits into
apache:mainfrom
shapeblue:instance-from-backup

Conversation

@abh1sar

@abh1sarabh1sar commented Dec 25, 2024

Copy link
Copy Markdown
Contributor

Doc PR: apache/cloudstack-documentation#474

Description

This PR adds the ability to create a new Instance from a VM backup for Dummy, NAS and Veeam backup Providers.
This will still work if the original Instance used to create the backup was expunged.
Design doc : https://cwiki.apache.org/confluence/display/CLOUDSTACK/Create+Instance+from+Backup

Other Miscellaneous changes

  1. Framework level enhancements
    a. Set name and description for backups
    b. Show interval type for backup schedule in UI
    c. Improve backup search in ui by keyword
  2. NAS backup provider enhancements
    a. Improved error logging and handling
    b. Quiesce instance option during backup create
  3. Backup And Object storage capacity tracking and alerts.

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)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

Screenshot 2025-01-14 at 2 17 16 PMScreenshot 2025-01-14 at 2 17 35 PM

How Has This Been Tested?

1. Create Instance from Backup

Test CaseNotes
Create VM from backup using default metadata (no overrides)Validated for all providers
Create VM from backup with custom service offeringService Offering used and Disk size validation enforced
Create VM from backup with custom data volume sizesFails if smaller than original
Create VM with new IP/MAC (original instance not expunged)New IP/MAC allocated
Create VM with original IP/MAC (original instance expunged)Only works if IP is unassigned
Create VM from backup having ISOVerified that ISO is detached before boot
Create VM from backup having ISO with multiple data volumesVerified volume configurations
Create VM with SSH KeySSH-key access is there
Create VM with multiple data volumesAll volumes created and attached
Create VM from backup using default metadata after deleting templateProper error is thrown
Create VM from backup using default metadata after disabling service offeringProper error is thrown
Create VM from backup using default metadata after deleting networkProper error is thrown
Create VM from backup using default metadata after disabling disk offeringProper error is thrown

2. Expunge/Unmanage VM with Backups

Test CaseNotes
Remove backup offering from VM with backupsOffering removed, backups retained
Expunge VM with retained backupsVM deleted, backups remain usable
Attempt to delete backup after expunging source VMNo dependency on VM existence
Create VM from backup of an expunged instanceCreated as expected
Create VM from backup of an unmanaged instanceCreated as expected
Reassign new backup offering to the VM and trigger new backupNew backups tracked under new offering
Verify database entry for expunged VM is retainedEntry present as expected

3. Usage Tracking

Test CaseNotes
Usage tracked per (VM ID, Backup Offering ID)Validated in usage records
Metrics returned per tuple for all providers (NAS, Veeam, Dummy)As expected
Backup offering removal does not delete usage record if backups existUsage still visible in usage_vm_backup table
Usage record deleted only when last backup for offering is deletedVerified record purged post-delete
Usage metrics for expunged VMs retained and reportedAs expected

4. UI Validation

Test CaseNotes
“Create Instance from Backup” button appears in backup listUI shows proper dialog
Pre-filled config from backup metadata when clicked on ConfigureAll fields populated correctly
Volume details and limits correctly shown and enforcedVolume size limits shown
Use IP Addresses from Backup switch appears only when original VM is expungedAs expected
Multiple data volumes rendered correctly in UI formAs expected

5. Regression Tests

Test CaseNotes
Standard DeployVM API with different combinations of disk offerings, service offerings and ovverride root disk sizePass
Backup Schedule and Delete flowsPass
Restore BackupPass
Restore Volume and Attach to InstancePass
VM lifecycle commandsPass

How did you try to break this feature and the system with this change?

@codecov

codecovBot commented Dec 25, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.97744% with 1256 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.35%. Comparing base (70468a6) to head (226e82a).
⚠️ Report is 9 commits behind head on main.

Files with missing linesPatch %Lines
...loudstack/api/command/user/vm/BaseDeployVMCmd.java47.91%173 Missing and 39 partials ⚠️
...rg/apache/cloudstack/backup/BackupManagerImpl.java64.09%111 Missing and 61 partials ⚠️
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java44.25%125 Missing and 40 partials ⚠️
...ack/api/command/user/vm/CreateVMFromBackupCmd.java6.15%60 Missing and 1 partial ⚠️
...rg/apache/cloudstack/backup/NASBackupProvider.java34.40%58 Missing and 3 partials ⚠️
...rg/apache/cloudstack/backup/dao/BackupDaoImpl.java21.81%42 Missing and 1 partial ⚠️
.../apache/cloudstack/backup/DummyBackupProvider.java0.00%42 Missing ⚠️
...che/cloudstack/backup/NetworkerBackupProvider.java0.00%35 Missing ⚠️
.../apache/cloudstack/backup/VeeamBackupProvider.java5.88%32 Missing ⚠️
...a/org/apache/cloudstack/backup/BackupDetailVO.java18.91%29 Missing and 1 partial ⚠️
... and 47 more
Additional details and impacted files
@@ Coverage Diff @@## main #10140 +/- ##
============================================
+ Coverage 17.17% 17.35% +0.17% - Complexity 15010 15186 +176 
============================================
Files 5869 5883 +14 Lines 521710 524302 +2592 Branches 63509 63962 +453 ============================================
+ Hits 89614 90974 +1360 - Misses 422039 423051 +1012 - Partials 10057 10277 +220 
FlagCoverage Δ
uitests3.63% <ø> (-0.13%)⬇️
unittests18.38% <40.97%> (+0.22%)⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@leo79901

Copy link
Copy Markdown

Yes, we need this !

@abh1sar

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@abh1sar a [SL] 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 [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 11996

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] 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.

@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan ui

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti 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: https://qa.cloudstack.cloud/simulator/pr/10140 (QA-JID-703)

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14457

@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-13974)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 80618 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10140-t13974-kvm-ol8.zip
Smoke tests completed. 138 look OK, 8 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File
ContextSuite context=TestRAMCPUResourceAccounting>:setupError0.00test_resource_accounting.py
test_01_list_sec_storage_vmFailure0.05test_ssvm.py
test_03_ssvm_internalsFailure0.05test_ssvm.py
test_05_stop_ssvmFailure0.04test_ssvm.py
test_07_reboot_ssvmFailure0.05test_ssvm.py
test_11_destroy_ssvmFailure917.32test_ssvm.py
ContextSuite context=TestVMWareStoragePolicies>:setupError0.00test_storage_policy.py
test_01_create_templateError1.14test_templates.py
test_CreateTemplateWithDuplicateNameError1.11test_templates.py
test_02_create_template_with_checksum_sha1Error65.65test_templates.py
test_03_create_template_with_checksum_sha256Error65.63test_templates.py
test_04_create_template_with_checksum_md5Error65.64test_templates.py
test_05_create_template_with_no_checksumError65.63test_templates.py
ContextSuite context=TestTemplates>:setupError240.85test_templates.py
ContextSuite context=TestISOUsage>:setupError0.00test_usage.py
test_01_snapshot_usageError1.19test_usage.py
test_01_template_usageError1.20test_usage.py
test_01_volume_usageError130.86test_usage.py
test_06_download_detached_volumeError300.10test_volumes.py
test_13_migrate_volume_and_change_offeringError126.36test_volumes.py
ContextSuite context=TestIpv6Vpc>:setupError0.00test_vpc_ipv6.py
ContextSuite context=TestRVPCSite2SiteVpn>:setupError0.00test_vpc_vpn.py
ContextSuite context=TestVPCSite2SiteVPNMultipleOptions>:setupError0.00test_vpc_vpn.py
ContextSuite context=TestVpcRemoteAccessVpn>:setupError0.00test_vpc_vpn.py
ContextSuite context=TestVpcSite2SiteVpn>:setupError0.00test_vpc_vpn.py

@sureshanaparti

Copy link
Copy Markdown
Contributor

@abh1sar can you check the conflicts

@abh1sar

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@abh1sar a [SL] 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.

@abh1sar

Copy link
Copy Markdown
ContributorAuthor
  • Tried to create VM from backup and delete the backup before the process ends, the deletion was allowed but the VM was not restored. I think that these processes should be either blocked from executing at the same time, or be queued.

The processes are queued once they reach the agent. i.e, if the new instance is in Restoring state then backup is deleted, the agent will process the restore first and then backup delete. If the new instance is still being created/starting/stopping before restore, and the backup is deleted, delete is not blocked and restore will throw an error that backup is deleted. IMO this is not a must have, and I'll be happy to fix this as a future improvement.

Could we map it as an issue then?

Created issue #11356

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14488

@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@abh1sarabh1sar mentioned this pull request Jul 31, 2025
13 tasks
@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-13987)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 52137 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10140-t13987-kvm-ol8.zip
Smoke tests completed. 145 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File
test_01_list_sec_storage_vmFailure0.05test_ssvm.py
test_03_ssvm_internalsFailure0.04test_ssvm.py
test_05_stop_ssvmFailure0.04test_ssvm.py
test_11_destroy_ssvmError3.23test_ssvm.py
test_12_destroy_cpvmError3.19test_ssvm.py

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

12 participants

@abh1sar@leo79901@blueorangutan@shwstppr@weizhouapache@sureshanaparti@GutoVeronezi@yadvr@RosiKyu@JoaoJandre@DaanHoogland@rajujith