SURYAS1306 opened a new pull request, #12678:
URL: https://github.com/apache/cloudstack/pull/12678
### 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
actually mount 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 moves validation to storage addition time (fail-fast behavior).
This PR fixes the issue by performing **immediate NFS mount validation using
SSVM** during image store discovery:
* After datastore initialization,
`SecondaryStorageVmManager.generateSetupCommand()` is invoked
* If the SSVM fails to mount the storage:
* the created image store is rolled back
* a `CloudRuntimeException` is thrown
* the API returns failure instead of success
This behavior aligns secondary storage validation with primary storage
validation and prevents late failures during system VM template registration.
Fixes: #12674
---
### Types of changes
* [ ] Breaking change
* [ ] New feature
* [x] Bug fix
* [ ] Enhancement
* [ ] Cleanup
* [ ] Build/CI
* [ ] Test
---
### Bug Severity
* [ ] BLOCKER
* [ ] Critical
* [x] 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:
```bash
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]