Skip to content
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

backup: simple NAS backup plugin for KVM #9451

Merged

Conversation

rohityadavcloud
Copy link
Member

@rohityadavcloud rohityadavcloud commented Jul 26, 2024

This is a simple NAS backup plugin for KVM which may be later expanded for other hypervisors. This backup plugin aims to use shared NAS storage on KVM hosts such as NFS (or CephFS and others in future), which is used to backup fully cloned VMs for backup & restore operations. This may NOT be as efficient and performant as some of the other B&R providers, but maybe useful for some KVM environments who are okay to only have full-instance backups and limited functionality.

Design & Implementation follows the networker B&R plugin, which is simply:

  • Implement B&R plugin interfaces
  • Use cmd-answer pattern to execute backup and restore operations on KVM host when VM is running (or needs to be restored) - instead of a B&R API client, relies on answers from KVM agent which executes the operations
  • Backups are full VM domain snapshots, copied to a VM-specific folders on a NAS target (NFS) along with a domain XML
  • Backup uses libvirt feature: https://libvirt.org/kbase/live_full_disk_backup.html orchestrated via virsh/bash script (nasbackup.sh) as the libvirt-java lacks the bindings
  • Supported instance volume storage for restore operations: NFS & local storage

Refer the doc PR for feature limitations and usage details:
apache/cloudstack-documentation#429

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

Screenshots

Each backup offering map to a Backup repository that takes in backup storage details (address/url, credentials/mount options):
Screenshot 2024-08-02 at 5 32 41 PM

Rest is same as B&R feature works; we assign such offering to a VM and backup once completed shows up in the list:
Screenshot 2024-08-02 at 5 58 49 PM
Screenshot 2024-08-02 at 5 59 07 PM

This is an experimental simple NAS backup plugin for KVM which may be
later expanded for other hypervisors. This backup plugin aims to use
shared NAS storage on KVM hosts such as NFS or CephFS, which is used
to backup fully cloned VMs for backup & restore operations. This
may not be as efficient and performant as some of the other B&R
providers, but maybe useful for some KVM environments.

Signed-off-by: Rohit Yadav <[email protected]>
Copy link

codecov bot commented Jul 26, 2024

Codecov Report

Attention: Patch coverage is 0.62696% with 951 lines in your changes missing coverage. Please review.

Project coverage is 15.61%. Comparing base (605534b) to head (9efdb57).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...rg/apache/cloudstack/backup/NASBackupProvider.java 0.00% 218 Missing ⚠️
...ce/wrapper/LibvirtRestoreBackupCommandWrapper.java 0.81% 121 Missing ⚠️
...apache/cloudstack/backup/RestoreBackupCommand.java 0.00% 66 Missing ⚠️
...udstack/api/response/BackupRepositoryResponse.java 0.00% 63 Missing ⚠️
...g/apache/cloudstack/backup/BackupRepositoryVO.java 0.00% 56 Missing ⚠️
...cloudstack/backup/BackupRepositoryServiceImpl.java 0.00% 46 Missing ⚠️
...rg/apache/cloudstack/backup/TakeBackupCommand.java 0.00% 44 Missing ⚠️
...rg/apache/cloudstack/backup/BackupManagerImpl.java 4.34% 44 Missing ⚠️
...user/backup/repository/AddBackupRepositoryCmd.java 0.00% 43 Missing ⚠️
.../apache/cloudstack/backup/DeleteBackupCommand.java 0.00% 34 Missing ⚠️
... and 18 more
Additional details and impacted files
@@             Coverage Diff              @@
##              main    #9451       +/-   ##
============================================
+ Coverage     4.12%   15.61%   +11.49%     
- Complexity       0    12118    +12118     
============================================
  Files          383     5555     +5172     
  Lines        31354   486283   +454929     
  Branches      5551    61315    +55764     
============================================
+ Hits          1293    75945    +74652     
- Misses       29915   401966   +372051     
- Partials       146     8372     +8226     
Flag Coverage Δ
uitests 4.12% <ø> (+<0.01%) ⬆️
unittests 16.40% <0.62%> (?)

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.

@rohityadavcloud
Copy link
Member Author

Update: take backup & delete backup implemented for NFS; TBD/TODO more operations.

Each backup repository is for a specific zone & provider.
Eack NAS bkcp offering is tied to a back repo & each bkup offer assinged
to VM -> defined its backup repository

Signed-off-by: Rohit Yadav <[email protected]>
Signed-off-by: Rohit Yadav <[email protected]>
@rohityadavcloud
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

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

Copy link
Contributor

@sureshanaparti sureshanaparti left a comment

Choose a reason for hiding this comment

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

minor comments, overall code looks good.

rohityadavcloud and others added 4 commits September 5, 2024 16:36
Signed-off-by: Rohit Yadav <[email protected]>
(cherry picked from commit ecfeb04026e1bbf13dc22bb0aa713677c7708bb8)
Signed-off-by: Rohit Yadav <[email protected]>
@apache apache deleted a comment from blueorangutan Sep 5, 2024
@apache apache deleted a comment from blueorangutan Sep 5, 2024
Copy link
Collaborator

@rajujith rajujith left a comment

Choose a reason for hiding this comment

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

LGTM

  • Works with KVM EL8 ,EL9, Ubuntu22,Ubuntu24
  • Backup and restore works fine. All Full backups.
  • Supported backup repository NFS, tested using QNAP.
  • Parallel backups and restore
  • Parallel backups and restore per host.
  • Multiple Linux distros and Windows.
  • Multiple Backup repositories.
  • Backup schedules.
  • Admin and users can trigger backups.
  • Primary storages of type NFS and local storage.
  • Upgrade from 4.19.

Limitations observed and possible improvements( some are limitations of the B&R Framework itself)

  • Restoring expunged instances.
  • Restoring unmanaged instances.
  • More backup repository type support.
  • CKS support
  • Agent logging could be improved.

@rohityadavcloud
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

@rohityadavcloud 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 11006

@Pearl1594
Copy link
Contributor

Few comments will be addressed as improvements in a subsequent PR.

@rohityadavcloud
Copy link
Member Author

@blueorangutan test

@blueorangutan
Copy link

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

@rohityadavcloud
Copy link
Member Author

Merging this based on reviews, manual QA and GitHub Actions tests. Will continue further test matrix on health check PR.

@rohityadavcloud rohityadavcloud merged commit 85765c3 into apache:main Sep 5, 2024
25 of 26 checks passed
@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_01_secure_vm_migration Error 135.16 test_vm_life_cycle.py
test_01_secure_vm_migration Error 135.16 test_vm_life_cycle.py

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_mount_shared_fs Failure 84.98 test_sharedfs_lifecycle.py
test_resize_shared_fs Error 0.44 test_sharedfs_lifecycle.py

dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Sep 6, 2024
This is a simple NAS backup plugin for KVM which may be later expanded for other hypervisors. This backup plugin aims to use shared NAS storage on KVM hosts such as NFS (or CephFS and others in future), which is used to backup fully cloned VMs for backup & restore operations. This may NOT be as efficient and performant as some of the other B&R providers, but maybe useful for some KVM environments who are okay to only have full-instance backups and limited functionality.

Design & Implementation follows the `networker` B&R plugin, which is simply:

- Implement B&R plugin interfaces
- Use cmd-answer pattern to execute backup and restore operations on KVM host when VM is running (or needs to be restored) - instead of a B&R API client, relies on answers from KVM agent which executes the operations
- Backups are full VM domain snapshots, copied to a VM-specific folders on a NAS target (NFS) along with a domain XML
- Backup uses libvirt feature: https://libvirt.org/kbase/live_full_disk_backup.html orchestrated via virsh/bash script (nasbackup.sh) as the libvirt-java lacks the bindings
- Supported instance volume storage for restore operations: NFS & local storage

Refer the doc PR for feature limitations and usage details:
apache/cloudstack-documentation#429

Signed-off-by: Rohit Yadav <[email protected]>
Co-authored-by: Pearl Dsilva <[email protected]>
Co-authored-by: Abhishek Kumar <[email protected]>
Co-authored-by: Suresh Kumar Anaparti <[email protected]>
@Pearl1594 Pearl1594 mentioned this pull request Sep 30, 2024
14 tasks
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