Skip to content

volume: enforce storage pool disable threshold when creating a volume on an explicit pool - #14071

Open
weizhouapache wants to merge 2 commits into
apache:mainfrom
weizhouapache:claude/volume-pool-disablethreshold-check-8a675a
Open

volume: enforce storage pool disable threshold when creating a volume on an explicit pool#14071
weizhouapache wants to merge 2 commits into
apache:mainfrom
weizhouapache:claude/volume-pool-disablethreshold-check-8a675a

Conversation

@weizhouapache

@weizhouapache weizhouapache commented Sep 7, 2026

Copy link
Copy Markdown
Member

Description

createVolume accepts an admin-only storageid parameter to create the volume directly on a specified storage pool. Unlike the normal allocation path (which goes through StoragePoolAllocatorStorageManager.storagePoolHasEnoughSpacecheckUsagedSpace), this path fetched the pool directly by ID and only validated pool status, zone match, and disk-offering compatibility — it never checked the pool's storage capacity disable threshold (storage.capacity.disablethreshold) or allocated-capacity disable threshold before creating the volume there.

This means an admin passing storageid could push a storage pool past its configured disable threshold, defeating the safety mechanism the threshold exists for.

This is not considered a security issue since the storageid parameter is restricted to RoleType.Admin (added in 4.22.1), but it is a correctness bug.

Fix

VolumeApiServiceImpl#createVolumeOnStoragePool now calls StorageManager#storagePoolHasEnoughSpace (the same check used by migrateVolume) before handing the volume off to VolumeService#createVolumeAsync, and rejects the request with an InvalidParameterValueException if the pool has crossed its disable threshold or doesn't have enough space.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)

Feature/Enhancement Scale or Bug Severity

Bug Severity: Minor

Screenshots (if appropriate):

N/A

How Has This Been Tested?

Added unit tests to VolumeApiServiceImplTest:

  • testCreateVolumeOnStoragePool_DisableThresholdCrossed_ShouldThrow — verifies an InvalidParameterValueException is thrown and createVolumeAsync is never invoked when the pool has crossed its disable threshold.
  • testCreateVolumeOnStoragePool_EnoughSpace_ShouldCreateVolume — verifies the volume is created normally when the pool has enough space.

Ran the full VolumeApiServiceImplTest suite (161 tests, 0 failures).

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings September 7, 2026 12:41
@weizhouapache
weizhouapache force-pushed the claude/volume-pool-disablethreshold-check-8a675a branch from d94ed21 to a9ef05a Compare September 7, 2026 12:41

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.

🟡 Changes recommended

It includes unrelated repository governance/workflow configuration changes that should be split out or explicitly justified to avoid surprising operational impact.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes a correctness gap in the admin-only storageid volume creation path by enforcing storage pool disable-threshold / capacity checks (consistent with the normal allocation path), preventing an explicit-pool create from bypassing configured safety limits.

Changes:

  • Add a StorageManager#storagePoolHasEnoughSpace(...) check to VolumeApiServiceImpl#createVolumeOnStoragePool before dispatching async volume creation.
  • Add unit tests covering the “disable threshold crossed” rejection and “enough space” success cases.
  • Update repository/workflow governance configuration (branch protection rules + workflow activation guard).
File summaries
File Description
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java Enforces storage pool capacity/disable-threshold checks when creating a volume on an explicitly specified pool.
server/src/test/java/com/cloud/storage/VolumeApiServiceImplTest.java Adds unit tests validating rejection when thresholds are crossed and success when capacity is sufficient.
.github/workflows/daily-issue-triage.lock.yml Adds a job-level repository guard to prevent activation outside apache/cloudstack.
.asf.yaml Expands branch protection coverage to maintenance branches and adds required reviews/status checks.
Review details

Suppressed comments (1)

.asf.yaml:84

  • This required-status-checks block is also unrelated to the volume disable-threshold fix described in the PR. If it’s intended, it should be proposed separately (or at least called out in the PR description), since it can affect mergeability across branches.
      required_status_checks:
        - "Build / build"
        - "pre-commit / Run pre-commit"
        - "UI Build / build"
        - "Simulator CI / build"
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

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

Comment thread .asf.yaml Outdated
Comment thread .github/workflows/daily-issue-triage.lock.yml
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 19.78%. Comparing base (44ab7dd) to head (8cdd0f1).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main   #14071   +/-   ##
=========================================
  Coverage     19.77%   19.78%           
- Complexity    19989    19994    +5     
=========================================
  Files          6371     6371           
  Lines        575899   575909   +10     
  Branches      70495    70497    +2     
=========================================
+ Hits         113912   113959   +47     
+ Misses       449563   449515   -48     
- Partials      12424    12435   +11     
Flag Coverage Δ
uitests 3.53% <ø> (-0.01%) ⬇️
unittests 21.06% <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.

… on an explicit pool

createVolume with an admin-specified storageid bypassed the normal
allocator path and thus skipped the pool's disable-threshold and
allocated-capacity checks (checkUsagedSpace / checkPoolforSpace).
createVolumeOnStoragePool now calls StorageManager.storagePoolHasEnoughSpace
before creating the volume, matching the check already done for
volume migration.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 7, 2026 13:22
@weizhouapache
weizhouapache force-pushed the claude/volume-pool-disablethreshold-check-8a675a branch from a9ef05a to d3dc85d Compare September 7, 2026 13:22
@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

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.

🟡 Changes recommended

The updated method still performs a redundant second datastore lookup after validating the first instance, which should be removed to avoid inconsistency and simplify the flow.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java Outdated
Copilot AI review requested due to automatic review settings September 7, 2026 14:08
@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

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.

🟡 Changes recommended

createVolumeOnStoragePool currently contains an unclosed if block/missing exception around the new capacity check, which breaks compilation and fails to enforce the intended rejection behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
Copilot AI review requested due to automatic review settings September 7, 2026 14:19
@weizhouapache
weizhouapache force-pushed the claude/volume-pool-disablethreshold-check-8a675a branch from 71432cf to 8cdd0f1 Compare September 7, 2026 14:19
@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@weizhouapache weizhouapache added this to the 24.0 milestone Sep 7, 2026
@blueorangutan

Copy link
Copy Markdown

@weizhouapache 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]: ✖️ debian. SL-JID 19134

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.

🟢 Approval recommended

The change aligns the explicit-pool creation path with existing capacity/disable-threshold enforcement and includes targeted unit tests for both failure and success cases.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

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.

3 participants