cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Prioritize copying templates from other secondary storages instead of downloading them

Open winterhazel opened this issue 10 months ago • 26 comments

Description

After adding a new secondary storage, CloudStack will always try to download public templates/ISOs that have URLs from the source to the new secondary storage, even if it already exists on another one. Due to this behavior, if the URL does not exist anymore, the template will not become available at the new storage; and if the template has been updated at the source, it will not be installed because of checksum mismatch. This forces operators to manually copy/move templates to the new secondary storage.

To solve this issue, this PR creates the zone-scoped setting copy.public.templates.from.other.storages. When enabled, CloudStack will try to copy templates/ISOs from other secondary storages in the same zone before attempting to downloading them from the source. It is enabled by default.

Types of changes

  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [X] 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
  • [X] Minor

How Has This Been Tested?

With the setting enabled

  1. I deleted all existing secondary storages, and registered an empty one (SS 1). I verified that the SSVM started to download the templates that were registered.

  2. I registered another template, and immediately also registered secondary storage 2. I verified that the templates available in SS 1 were copied to SS 2, and that the last registered template was being downloaded to both secondary storages.

  3. Inside SS 1, I deleted the first half of templates; inside SS 2, I deleted the other half of templates. Then, I added SS 3. I verified that all the templates were copied to SS 3. SS 1 and SS 2 were not synchronized yet, so they still had only half of the templates each.

  4. I restarted the SSVM's service. I verified that the first half of templates was copied from SS 1 to SS 2, and that the other half was copied from SS 2 to SS 1.

  5. I deleted SS 1 and SS 2. Then, I deployed a VM using each one of the templates, and verified that they were deployed successfully.

With the setting disabled

  1. I disabled the setting and added SS 4. I verified that the SSVM started to download the templates to SS 4 from the source instead of copying them.

  2. Migration: I marked all templates as private so that they are not downloaded to new secondary storages. Then, I added SS 5 and called migrateSecondaryStorageData to migrate data from SS 4 to SS 5. I verified that the templates were migrated successfully.

winterhazel avatar Feb 11 '25 02:02 winterhazel

@blueorangutan package

winterhazel avatar Feb 11 '25 02:02 winterhazel

@winterhazel 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 avatar Feb 11 '25 02:02 blueorangutan

Codecov Report

:x: Patch coverage is 13.87755% with 211 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 16.23%. Comparing base (494c56a) to head (a2a9559).

Files with missing lines Patch % Lines
...tack/engine/orchestration/StorageOrchestrator.java 0.00% 93 Missing :warning:
.../cloudstack/storage/image/TemplateServiceImpl.java 33.67% 65 Missing :warning:
...ack/engine/orchestration/DataMigrationUtility.java 0.00% 53 Missing :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #10363      +/-   ##
============================================
+ Coverage     16.22%   16.23%   +0.01%     
- Complexity    13358    13371      +13     
============================================
  Files          5657     5657              
  Lines        498686   498854     +168     
  Branches      60526    60539      +13     
============================================
+ Hits          80918    81003      +85     
- Misses       408744   408820      +76     
- Partials       9024     9031       +7     
Flag Coverage Δ
uitests 4.00% <ø> (ø)
unittests 17.09% <13.87%> (+0.01%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov[bot] avatar Feb 11 '25 02:02 codecov[bot]

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

blueorangutan avatar Feb 11 '25 04:02 blueorangutan

@blueorangutan package

winterhazel avatar Feb 24 '25 12:02 winterhazel

@winterhazel 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 avatar Feb 24 '25 12:02 blueorangutan

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

blueorangutan avatar Feb 24 '25 13:02 blueorangutan

@blueorangutan package

winterhazel avatar Feb 25 '25 13:02 winterhazel

@winterhazel 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 avatar Feb 25 '25 13:02 blueorangutan

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

blueorangutan avatar Feb 25 '25 14:02 blueorangutan

@winterhazel I marked this for 4.21 as it is based off main, but would this be a good improvement for 4.20.1 as well?

DaanHoogland avatar Feb 26 '25 13:02 DaanHoogland

@winterhazel could you fix the compilation errors?

JoaoJandre avatar Feb 26 '25 15:02 JoaoJandre

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

blueorangutan avatar Feb 26 '25 15:02 blueorangutan

@winterhazel I marked this for 4.21 as it is based off main, but would this be a good improvement for 4.20.1 as well?

Yeah, it would be great to have it in 4.20.1. I'll rebase.

winterhazel avatar Feb 26 '25 17:02 winterhazel

@blueorangutan package

winterhazel avatar Feb 26 '25 17:02 winterhazel

@winterhazel 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 avatar Feb 26 '25 17:02 blueorangutan

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

blueorangutan avatar Feb 26 '25 19:02 blueorangutan

@blueorangutan test

DaanHoogland avatar Feb 27 '25 15:02 DaanHoogland

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

blueorangutan avatar Feb 27 '25 15:02 blueorangutan

[SF] Trillian test result (tid-12507) Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8 Total time taken: 64197 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10363-t12507-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
test_06_purge_expunged_vm_background_task Failure 427.51 test_purge_expunged_vms.py

blueorangutan avatar Feb 28 '25 10:02 blueorangutan

@blueorangutan package

weizhouapache avatar Sep 11 '25 10:09 weizhouapache

@weizhouapache 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 avatar Sep 11 '25 10:09 blueorangutan

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

blueorangutan avatar Sep 11 '25 13:09 blueorangutan

@weizhouapache , this seems a non-functional change and an improvement. Can we mark it for a future 4.20 update if it doesn’t make 4.20.2?

DaanHoogland avatar Sep 15 '25 09:09 DaanHoogland

@weizhouapache , this seems a non-functional change and an improvement. Can we mark it for a future 4.20 update if it doesn’t make 4.20.2?

@DaanHoogland I moved it to 4.20.3 milestone and let the next RM to decide

weizhouapache avatar Sep 15 '25 10:09 weizhouapache

[SF] Trillian Build Failed (tid-14934)

blueorangutan avatar Dec 09 '25 10:12 blueorangutan

@blueorangutan package

winterhazel avatar Dec 14 '25 00:12 winterhazel

@winterhazel 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 avatar Dec 14 '25 00:12 blueorangutan

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

blueorangutan avatar Dec 14 '25 01:12 blueorangutan

@blueorangutan test

harikrishna-patnala avatar Dec 15 '25 10:12 harikrishna-patnala