Skip to content

storage: validate NFS secondary storage mount using SSVM during image store discovery#12678

Open
SURYAS1306 wants to merge 2 commits intoapache:4.22from
SURYAS1306:fix-nfs-secondary-validation-12674
Open

storage: validate NFS secondary storage mount using SSVM during image store discovery#12678
SURYAS1306 wants to merge 2 commits intoapache:4.22from
SURYAS1306:fix-nfs-secondary-validation-12674

Conversation

@SURYAS1306
Copy link

@SURYAS1306 SURYAS1306 commented Feb 21, 2026

###Description

This PR addresses issue #12674 where CloudStack allows adding a secondary storage (image store) even when the provided NFS mount path is invalid.

Currently during image store discovery, CloudStack persists the image store in the database without validating whether the Secondary Storage VM (SSVM) can access the NFS export.
The failure only appears later during system VM template seeding (setup-sysvm-tmplt), producing errors in logs while the API/UI reports successful storage addition.

This leads to an inconsistent state where unusable secondary storage is registered in the system.

Previously validation occurred only during System VM template seeding; this change introduces fail-fast validation during image store discovery.

This PR performs immediate validation using SSVM during image store discovery:

  • During discovery, the management server sends a setup command (generateSetupCommand) to an available SSVM in the same zone to verify the storage can be prepared/mounted.
  • If the SSVM setup command fails:

    • the created image store is rolled back
    • a CloudRuntimeException is thrown
    • the API returns failure instead of success

This prevents unusable secondary storage from being registered and avoids late failures during system VM template registration.

Fixes: #12674


Types of changes

  • Breaking change
  • New feature
  • Bug fix
  • Enhancement
  • Cleanup
  • Build/CI
  • Test

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

Environment

  • Apache CloudStack 4.22
  • KVM hypervisor
  • NFS secondary storage

Test Scenarios

  1. Valid NFS mount

    • Secondary storage added successfully
    • SSVM mount successful
    • Templates seeded correctly
  2. Invalid NFS mount

    • API returns error
    • Image store not persisted in database
    • No template seeding attempted
  3. Regression check

    • Primary storage behavior unchanged
    • Existing valid secondary storages unaffected

Unit tests executed:

mvn -pl server -Dtest=StorageManagerImplTest,SecondaryStorageManagerImplTest test

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

  • Wrong NFS export path
  • Non-exported directory
  • Unreachable NFS server IP

In all cases, storage creation failed correctly and no invalid store was registered.

Copy link
Contributor

@shwstppr shwstppr left a comment

Choose a reason for hiding this comment

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

Will need validation for a new zone

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

This PR aims to prevent registering unusable NFS secondary storage by performing fail-fast validation during image store discovery, using a Secondary Storage VM (SSVM) to verify the mount before proceeding.

Changes:

  • Injects SecondaryStorageVmManager into StorageManagerImpl.
  • Adds SSVM-based validation logic inside discoverImageStore and rolls back the image store on validation failure.
  • Returns an error to the API caller when SSVM setup/mount validation fails.

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

@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

❌ Patch coverage is 0% with 53 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.60%. Comparing base (5caf6cd) to head (174b37d).

Files with missing lines Patch % Lines
...ain/java/com/cloud/storage/StorageManagerImpl.java 0.00% 53 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #12678      +/-   ##
============================================
- Coverage     17.60%   17.60%   -0.01%     
- Complexity    15659    15660       +1     
============================================
  Files          5917     5917              
  Lines        531394   531447      +53     
  Branches      64970    64977       +7     
============================================
- Hits          93575    93563      -12     
- Misses       427269   427335      +66     
+ Partials      10550    10549       -1     
Flag Coverage Δ
uitests 3.70% <ø> (ø)
unittests 18.67% <0.00%> (-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.

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