Skip to content

Create new Instance from VM backup #10140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 92 commits into
base: main
Choose a base branch
from

Conversation

abh1sar
Copy link
Collaborator

@abh1sar abh1sar commented Dec 25, 2024

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.

New API

  • createVmFromBackup extends deployVIrtualMachine
  • new argument : backupId
  • User can just specify the backupId and a new instance will be created by getting the VM and volumes' configuration stored in backup_details table.
  • User can also choose to configure the details themselves using the parameters present in deployVIrtualMachine cmd

UI

  • New action button in backups list view - 'Create Instance from Backup'
  • User can choose to directly create the VM or configure VM parameters before creating it.

DB changes

  • New backup_details table
  • to store vm config data such as templateUuid, serviceOfferingUuid, hypervisor, networkUuids
  • to store volumes config data such as diskOfferingUuids, size, miniops and maxiops for custom disk offerings.

Other Changes

  • Added new parameter Map datadisksdetails to deployVirtualMachine api to create multiple data volumes at the time of instance creation.

Plugins related changes

  • NAS and Veeam plugin changes to restore backup to a new VM.

Other Miscellaneous changes

  1. Add Name and description column to backup
  2. Show Interval type in UI for backups
  3. Support cephFS for NAS backup provider
  4. Add Backup Storage Capacity Tracking and Alerts Infrastructure
    Backup Storage (used and available) is shown on the Capacity dashboard and tracks the alerts if supported by the plugin
    (Currently only NAS BnR plugin supports it)
  5. Add Object Storage Capacity Tracking and Alerts Infrastructure
    Object Storage (allocated and available) is shown on the Capacity dashboard and tracked for 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 PM Screenshot 2025-01-14 at 2 17 35 PM

How Has This Been Tested?

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

Copy link

codecov bot commented Dec 25, 2024

Codecov Report

Attention: Patch coverage is 33.05589% with 1126 lines in your changes missing coverage. Please review.

Project coverage is 16.45%. Comparing base (f275c28) to head (e2fa0be).
Report is 50 commits behind head on main.

Files with missing lines Patch % Lines
...loudstack/api/command/user/vm/BaseDeployVMCmd.java 15.80% 289 Missing and 36 partials ⚠️
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 30.34% 133 Missing and 30 partials ⚠️
...rg/apache/cloudstack/backup/BackupManagerImpl.java 75.17% 39 Missing and 30 partials ⚠️
...ack/api/command/user/vm/CreateVMFromBackupCmd.java 6.45% 58 Missing ⚠️
...rg/apache/cloudstack/backup/dao/BackupDaoImpl.java 37.33% 41 Missing and 6 partials ⚠️
...a/org/apache/cloudstack/backup/BackupDetailVO.java 18.91% 29 Missing and 1 partial ⚠️
...rg/apache/cloudstack/backup/NASBackupProvider.java 50.00% 27 Missing and 3 partials ⚠️
.../apache/cloudstack/backup/VeeamBackupProvider.java 6.25% 30 Missing ⚠️
...che/cloudstack/backup/NetworkerBackupProvider.java 0.00% 25 Missing ⚠️
...loudstack/backup/GetBackupStorageStatsCommand.java 18.51% 22 Missing ⚠️
... and 38 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #10140      +/-   ##
============================================
+ Coverage     16.30%   16.45%   +0.14%     
- Complexity    13447    13608     +161     
============================================
  Files          5675     5688      +13     
  Lines        499249   501615    +2366     
  Branches      60377    60780     +403     
============================================
+ Hits          81415    82548    +1133     
- Misses       408761   409824    +1063     
- Partials       9073     9243     +170     
Flag Coverage Δ
uitests 3.86% <ø> (-0.14%) ⬇️
unittests 17.36% <33.05%> (+0.19%) ⬆️

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

Yes, we need this !

@abh1sar
Copy link
Collaborator Author

abh1sar commented Jan 6, 2025

@blueorangutan package

@blueorangutan
Copy link

@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

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

Copy link

github-actions bot commented Jan 8, 2025

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

@abh1sar
Copy link
Collaborator Author

abh1sar commented Apr 10, 2025

@blueorangutan package

@blueorangutan
Copy link

@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

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

@abh1sar
Copy link
Collaborator Author

abh1sar commented Apr 14, 2025

@blueorangutan package

@blueorangutan
Copy link

@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

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

@abh1sar
Copy link
Collaborator Author

abh1sar commented Apr 14, 2025

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

Test Result Time (s) Test File
ContextSuite context=TestClusterDRS>:setup Error 0.00 test_cluster_drs.py

@apache apache deleted a comment from blueorangutan Apr 16, 2025
@weizhouapache
Copy link
Member

overall lgtm

note about the setDeviceId

  • for vm created from template, the data volume uses diskofferingId , so deviceId=1 is correct
  • for vm created from ISO, the root volume uses diskofferingId , deviceId should be 0 I think.
  • for vm created with multiple data disks, it uses datadiskofferinglist, but deviceId of volumes are not set in dataDiskOfferingInfo.

is deviceId important for this feature ? cc @abh1sar

@abh1sar
Copy link
Collaborator Author

abh1sar commented Apr 16, 2025

Thanks @weizhouapache

  • for vm created from ISO, the root volume uses diskofferingId , deviceId should be 0 I think.

I tested this. The root volume is being assigned deviceId 0 for both template and iso.

  • for vm created with multiple data disks, it uses datadiskofferinglist, but deviceId of volumes are not set in dataDiskOfferingInfo.

deviceIds are set here

    public List<DiskOfferingInfo> getDataDiskOfferingListFromBackup(Backup backup) {
        ...
       diskOfferingInfoList.add(new DiskOfferingInfo(diskOffering, size, minIops, maxIops, deviceId));

Please let me know if this sounds ok.

@weizhouapache
Copy link
Member

Thanks @weizhouapache

  • for vm created from ISO, the root volume uses diskofferingId , deviceId should be 0 I think.

I tested this. The root volume is being assigned deviceId 0 for both template and iso.

  • for vm created with multiple data disks, it uses datadiskofferinglist, but deviceId of volumes are not set in dataDiskOfferingInfo.

deviceIds are set here

    public List<DiskOfferingInfo> getDataDiskOfferingListFromBackup(Backup backup) {
        ...
       diskOfferingInfoList.add(new DiskOfferingInfo(diskOffering, size, minIops, maxIops, deviceId));

Please let me know if this sounds ok.

thanks @abh1sar
good to know it

About the deviceId of datadiskoffering

dataDiskOfferingInfo.setDeviceId(1L);

should it be 0 if the vm is created from ISO ?
this is not a valid question if we do not support backup actions for vm from ISO.

@abh1sar
Copy link
Collaborator Author

abh1sar commented Apr 18, 2025

About the deviceId of datadiskoffering

dataDiskOfferingInfo.setDeviceId(1L);

should it be 0 if the vm is created from ISO ? this is not a valid question if we do not support backup actions for vm from ISO.

@weizhouapache For VM from ISOs createVirtualMachineFromScratch is called where deviceId remains null in rootDiskOfferingInfo and in allocateRawVolume the deviceId for volume is set to 0L.

        if (deviceId != null) {
            vol.setDeviceId(deviceId);
        } else if (type.equals(Type.ROOT)) {
            vol.setDeviceId(0l);

@abh1sar
Copy link
Collaborator Author

abh1sar commented Apr 23, 2025

@blueorangutan package

@blueorangutan
Copy link

@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
Collaborator Author

abh1sar commented Apr 23, 2025

@blueorangutan package

@blueorangutan
Copy link

@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

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

@blueorangutan
Copy link

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

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.

7 participants