Skip to content

extensions: ignore removed offerings when removing a network service - #14370

Open
DaanHoogland wants to merge 1 commit into
mainfrom
extension-ignore-removed-offerings-on-service-removal
Open

DaanHoogland wants to merge 1 commit into
mainfrom
extension-ignore-removed-offerings-on-service-removal

Conversation

@DaanHoogland

Copy link
Copy Markdown
Contributor

Description

This PR... fixes an issue reported by claude code during extension development

It fixes updateExtension refusing to remove a service from a NetworkOrchestrator extension's network.services detail after the only offering using it has been deleted.

deleteNetworkOffering (and VPC offering deletion) only marks the offering as removed; its rows in ntwk_offering_service_map / vpc_offering_service_map remain. The in-use check in ExtensionsManagerImpl.updateNetworkExtensionServicesOnPhysicalNetworks looked only at those map rows, so it kept failing with:

Cannot remove service CustomAction from extension '<name>' as it is used by a network/VPC offering

The check now resolves each mapped offering ID through NetworkOfferingDao / VpcOfferingDao and only counts offerings that are not removed.

updateExtension refused to drop a service from a NetworkOrchestrator
extension's network.services detail if any ntwk_offering_service_map or
vpc_offering_service_map row referenced it for the extension provider.
Deleting an offering only sets its removed date and keeps those map rows,
so a service stayed "in use" forever once any offering had used it.

Only count offerings that still exist (findById excludes removed rows)
when checking whether a service can be removed.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

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?

@DaanHoogland
DaanHoogland requested review from weizhouapache and a balanced review from Copilot October 8, 2026 16:28
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 19.90%. Comparing base (17294ca) to head (69183a9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14370      +/-   ##
============================================
- Coverage     19.91%   19.90%   -0.01%     
- Complexity    20198    20201       +3     
============================================
  Files          6373     6373              
  Lines        577234   577236       +2     
  Branches      70696    70696              
============================================
- Hits         114945   114925      -20     
- Misses       449724   449755      +31     
+ Partials      12565    12556       -9     
Flag Coverage Δ
uitests 3.70% <ø> (ø)
unittests 21.18% <100.00%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open findings
What changed in this PR

Fixes updateExtension incorrectly blocking removal of a network service from a NetworkOrchestrator extension when only removed network/VPC offerings still reference the service via persisted service-map rows.

Changes:

  • Update in-use checks to ignore deleted (removed) offerings by resolving offering IDs through DAOs.
  • Add DAO injections for NetworkOfferingDao and VpcOfferingDao.
  • Extend unit tests to cover “service-map rows exist but offerings are removed” behavior.
File Description
framework/​extensions/​src/​main/​java/​org/​apache/​cloudstack/​framework/​extensions/​manager/​ExtensionsManagerImpl.java Adjusts “service in use” logic to ignore removed offerings by checking offering existence via DAOs.
framework/​extensions/​src/​test/​java/​org/​apache/​cloudstack/​framework/​extensions/​manager/​ExtensionsManagerImplTest.java Updates existing tests and adds a new test ensuring removed offerings don’t block service removal.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +1318 to +1322
boolean usedByNetworkOffering = networkOfferingServiceMapDao
.listOfferingIdsByServiceAndProvider(removedService, extension.getName()).stream()
.anyMatch(offeringId -> networkOfferingDao.findById(offeringId) != null);
boolean usedByVpcOffering = vpcOfferingServiceMapDao
.listOfferingIdsByServiceAndProvider(removedService, extension.getName()).stream()
Comment on lines +1318 to +1323
boolean usedByNetworkOffering = networkOfferingServiceMapDao
.listOfferingIdsByServiceAndProvider(removedService, extension.getName()).stream()
.anyMatch(offeringId -> networkOfferingDao.findById(offeringId) != null);
boolean usedByVpcOffering = vpcOfferingServiceMapDao
.listOfferingIdsByServiceAndProvider(removedService, extension.getName()).stream()
.anyMatch(offeringId -> vpcOfferingDao.findById(offeringId) != null);
extensionsManager.updateNetworkExtensionServicesOnPhysicalNetworks(ext,
Set.of(Network.Service.CustomAction), Set.of(Network.Service.UserData));

ArgumentCaptor<List<Network.Service>> captor = ArgumentCaptor.forClass(List.class);
@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

🔴 Test Coverage Grade: D — Marginal

Metric Value
Line coverage 24.82%
Branch coverage 19.04%

Grade Scale

Grade Line Coverage Meaning
🟢 A ≥ 80% Excellent - this code sleeps well at night 😴
🟡 B 60-79% Good - almost there, don't stop now 😉
🟠 C 40-59% Acceptable - your code is wearing a seatbelt, but no airbags 😬
🔴 D 20-39% Marginal - boldly shipping where no test has gone before 🖖
⛔ F < 20% Failing - tests? what tests? 🔥

Branch coverage is shown as a secondary signal. Grade is determined by line coverage.
View full Actions run

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants