Skip to content

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

Open
DaanHoogland wants to merge 3 commits into
mainfrom
extension-ignore-removed-offerings-on-service-removal
Open

DaanHoogland wants to merge 3 commits 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 20.73%. Comparing base (a8200cf) to head (3d8d704).

Additional details and impacted files
@@             Coverage Diff              @@
##              main   #14370       +/-   ##
============================================
+ Coverage     3.86%   20.73%   +16.86%     
- Complexity       0    20786    +20786     
============================================
  Files          494     6049     +5555     
  Lines        42875   547785   +504910     
  Branches      8136    73176    +65040     
============================================
+ Hits          1657   113573   +111916     
- Misses       40986   420893   +379907     
- Partials       232    13319    +13087     
Flag Coverage Δ
uitests 3.86% <ø> (ø)
unittests 22.16% <100.00%> (?)

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 +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);
@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 25.64%
Branch coverage 20.79%

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

@DaanHoogland DaanHoogland added this to the 24.0 milestone Oct 22, 2026
@DaanHoogland
DaanHoogland force-pushed the extension-ignore-removed-offerings-on-service-removal branch from 69183a9 to 1acbd8d Compare November 9, 2026 14:03
Copilot AI balanced review requested due to automatic review settings November 9, 2026 14:03

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 08:54
@boring-cyborg boring-cyborg Bot added component:integration-test Python Warning... Python code Ahead! labels Nov 10, 2026

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@DaanHoogland

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with no 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 19971

@DaanHoogland

Copy link
Copy Markdown
Contributor Author

rebuilding debian package

@DaanHoogland

Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

Test Result Time (s) Test File
test_uservm_host_control_state Failure 17.20 test_host_control_state.py
test_CRUD_operations_userdata Error 1521.11 test_register_userdata.py
test_deploy_vm_with_registered_userdata Error 6.68 test_register_userdata.py
test_deploy_vm_with_registered_userdata_with_override_policy_allow Error 6.54 test_register_userdata.py
test_deploy_vm_with_registered_userdata_with_override_policy_append Error 6.60 test_register_userdata.py
test_deploy_vm_with_registered_userdata_with_override_policy_deny Error 6.34 test_register_userdata.py
test_deploy_vm_with_registered_userdata_with_params Error 6.31 test_register_userdata.py
test_link_and_unlink_userdata_to_template Error 6.48 test_register_userdata.py
test_user_userdata_crud Error 8.59 test_register_userdata.py
ContextSuite context=TestResetVmOnReboot>:setup Error 0.00 test_reset_vm_on_reboot.py
ContextSuite context=TestRAMCPUResourceAccounting>:setup Error 0.00 test_resource_accounting.py
test_03_register_template Error 1.18 test_resource_names.py
ContextSuite context=TestRestoreVM>:setup Error 0.00 test_restore_vm.py
ContextSuite context=TestRouterDHCPHosts>:setup Error 0.00 test_router_dhcphosts.py
ContextSuite context=TestRouterDHCPOpts>:setup Error 0.00 test_router_dhcphosts.py
ContextSuite context=TestRouterDns>:setup Error 0.00 test_router_dns.py
ContextSuite context=TestRouterDnsService>:setup Error 0.00 test_router_dnsservice.py
ContextSuite context=TestSslOffloading>:setup Error 0.00 test_ssl_offloading.py
ContextSuite context=TestRouterIpTablesPolicies>:setup Error 0.00 test_routers_iptables_default_policy.py
ContextSuite context=TestVPCIpTablesPolicies>:setup Error 0.00 test_routers_iptables_default_policy.py
ContextSuite context=TestIsolatedNetworks>:setup Error 0.00 test_routers_network_ops.py
ContextSuite context=TestRedundantIsolateNetworks>:setup Error 0.00 test_routers_network_ops.py
ContextSuite context=TestRouterServices>:setup Error 0.00 test_routers.py
ContextSuite context=TestCpuCapServiceOfferings>:setup Error 0.00 test_service_offerings.py
ContextSuite context=TestServiceOfferings>:setup Error 0.20 test_service_offerings.py
ContextSuite context=TestSetSourceNatIp>:setup Error 0.00 test_set_sourcenat.py
ContextSuite context=TestSnapshotRootDisk>:setup Error 0.00 test_snapshots.py
ContextSuite context=TestSnapshotStandaloneBackup>:setup Error 0.00 test_snapshots.py
test_2_userdata_on_cpvm Failure 97.42 test_systemvm_userdata.py
test_3_userdata_on_vr Failure 73.77 test_systemvm_userdata.py

@DaanHoogland
DaanHoogland force-pushed the extension-ignore-removed-offerings-on-service-removal branch from 11ca854 to 3d8d704 Compare November 12, 2026 13:47
Copilot AI balanced review requested due to automatic review settings November 12, 2026 13:47

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@DaanHoogland

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@sonarqubecloud

Copy link
Copy Markdown

@blueorangutan

Copy link
Copy Markdown

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

@weizhouapache weizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

code lgtm

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

component:integration-test Python Warning... Python code Ahead!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants