Skip to content

Fix Cross zone templates registration for Edge Zones#12874

Open
vishesh92 wants to merge 4 commits intoapache:4.22from
shapeblue:edge-zone-fix-cross-zone-template
Open

Fix Cross zone templates registration for Edge Zones#12874
vishesh92 wants to merge 4 commits intoapache:4.22from
shapeblue:edge-zone-fix-cross-zone-template

Conversation

@vishesh92
Copy link
Copy Markdown
Member

@vishesh92 vishesh92 commented Mar 23, 2026

Description

This PR fixes the registration of existing Cross Zone templates for Edge Zone.
This PR also offloads the filtering of cross zones to the database.

Details

This pull request refactors how cross-zone VM templates are handled and associated with zones. The main improvement is the introduction of a new DAO method, listAllCrossZoneTemplates(), which streamlines and centralizes the retrieval of cross-zone templates. This change eliminates repeated filtering logic across the codebase and makes the association process more efficient and maintainable. Additionally, the pull request updates the logic for associating these templates with zones, particularly in scenarios involving Edge Zones.

DAO and Data Access Improvements:

  • Added the listAllCrossZoneTemplates() method to the VMTemplateDao interface and its implementation, allowing efficient retrieval of only cross-zone templates without manual filtering. [1] [2] [3]
  • Updated the DAO search builder to include the crossZone property for filtering templates.

Refactoring Template Association Logic:

  • Replaced manual filtering of cross-zone templates in multiple locations (TemplateServiceImpl, SimulatorDiscoverer, SecondaryStorageDiscoverer, and StorageManagerImpl) with calls to the new listAllCrossZoneTemplates() method, simplifying and unifying the logic. [1] [2] [3] [4] [5]

Edge Zone Handling:

  • Modified ConfigurationManagerImpl to associate cross-zone templates with Edge Zones immediately upon creation, since Edge Zones do not have SSVMs to trigger this association later.

Dependency Injection and Imports:

  • Injected the TemplateService into ConfigurationManagerImpl to support the new association logic and added the necessary import. [1] [2]

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):

How Has This Been Tested?

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

@vishesh92
Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@vishesh92 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 17221

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 7.14286% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.60%. Comparing base (e93ae1a) to head (f0b7336).
⚠️ Report is 10 commits behind head on 4.22.

Files with missing lines Patch % Lines
.../cloudstack/storage/image/TemplateServiceImpl.java 0.00% 7 Missing ⚠️
.../java/com/cloud/storage/dao/VMTemplateDaoImpl.java 0.00% 6 Missing ⚠️
...n/java/com/cloud/resource/SimulatorDiscoverer.java 0.00% 5 Missing ⚠️
...k/storage/resource/SecondaryStorageDiscoverer.java 0.00% 5 Missing ⚠️
...ain/java/com/cloud/storage/StorageManagerImpl.java 0.00% 2 Missing ⚠️
...a/com/cloud/storage/download/DownloadListener.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #12874      +/-   ##
============================================
- Coverage     17.61%   17.60%   -0.01%     
- Complexity    15661    15674      +13     
============================================
  Files          5917     5917              
  Lines        531430   531633     +203     
  Branches      64973    64994      +21     
============================================
+ Hits          93586    93607      +21     
- Misses       427288   427468     +180     
- Partials      10556    10558       +2     
Flag Coverage Δ
uitests 3.70% <ø> (-0.01%) ⬇️
unittests 18.67% <7.14%> (-0.01%) ⬇️

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.

@vishesh92
Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@vishesh92 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 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17222

Copy link
Copy Markdown
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.

clgtm

@vishesh92
Copy link
Copy Markdown
Member Author

@blueorangutan test keepEnv

@blueorangutan
Copy link
Copy Markdown

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

@blueorangutan
Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-15725)

@blueorangutan
Copy link
Copy Markdown

[SF] Trillian test result (tid-15728)
Environment: kvm-ol9 (x2), zone: Advanced Networking with Mgmt server ol9
Total time taken: 57991 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12874-t15728-kvm-ol9.zip
Smoke tests completed. 148 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=TestSharedNetworkWithConfigDrive>:setup Error 50.50 test_network.py

@vishesh92 vishesh92 marked this pull request as ready for review March 30, 2026 06:49
@vishesh92
Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

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

@DaanHoogland DaanHoogland requested a review from Copilot March 30, 2026 07:43
@blueorangutan
Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes cross-zone VM template registration for Edge Zones by ensuring associations are created at zone creation time (since Edge Zones lack SSVM triggers) and centralizes cross-zone template retrieval via a new DAO method to avoid repeated in-memory filtering.

Changes:

  • Added VMTemplateDao.listAllCrossZoneTemplates() and updated DAO search criteria to DB-filter cross-zone templates.
  • Refactored multiple call sites to use TemplateService.associateCrossZoneTemplatesToZone(...) and updated method naming for consistency.
  • Ensured Edge Zones associate cross-zone templates during zone creation in ConfigurationManagerImpl.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/resource/SecondaryStorageDiscoverer.java Uses TemplateService to associate cross-zone templates per unique zone after discovery.
plugins/hypervisors/simulator/src/main/java/com/cloud/resource/SimulatorDiscoverer.java Switches discovery-time association to TemplateService (but currently leaves unused imports).
engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/TemplateService.java Renames API method to associateCrossZoneTemplatesToZone.
engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java Implements renamed method and uses DAO DB-filtered cross-zone template listing.
engine/schema/src/main/java/com/cloud/storage/dao/VMTemplateDao.java Adds listAllCrossZoneTemplates() to the DAO interface.
engine/schema/src/main/java/com/cloud/storage/dao/VMTemplateDaoImpl.java Implements listAllCrossZoneTemplates() and adds crossZone criterion to AllFieldsSearch.
server/src/main/java/com/cloud/storage/download/DownloadListener.java Updates call to renamed associateCrossZoneTemplatesToZone.
server/src/main/java/com/cloud/storage/StorageManagerImpl.java Delegates cross-zone association to TemplateService (leaves an unused local variable and legacy helper naming).
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java Associates cross-zone templates during Edge Zone creation.
server/src/test/java/com/cloud/configuration/ConfigurationManagerTest.java Adds a TemplateService mock to satisfy new injection in ConfigurationManagerImpl.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vishesh92 vishesh92 force-pushed the edge-zone-fix-cross-zone-template branch from 6a5b9b6 to f0b7336 Compare March 30, 2026 08:37
@DaanHoogland
Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@DaanHoogland 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 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17287

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.

6 participants