RosiKyu commented on issue #12415:
URL: https://github.com/apache/cloudstack/issues/12415#issuecomment-3748122594

   ## Reproduction Evidence (Clean Test)
   
   ### Configuration
   ```sql
   mysql> SELECT name, value FROM configuration WHERE 
name='secstorage.nfs.version';
   +------------------------+-------+
   | name                   | value |
   +------------------------+-------+
   | secstorage.nfs.version | NULL  |
   +------------------------+-------+
   ```
   
   ### MS sends NfsTO WITHOUT nfsVersion field
   ```
   2026-01-13 19:57:07,749 DEBUG [c.c.a.t.Request] Sending { Cmd ... 
   
"imageDataStore":{"com.cloud.agent.api.to.NfsTO":{"_url":"nfs://10.0.32.4/acs/secondary/.../sec5","_role":"Image"}}
   ```
   Note: No `nfsVersion` field in the NfsTO object.
   
   ### SSVM generates invalid mount command with `vers=null`
   ```
   2026-01-13T19:57:07,851 WARN [storage.resource.NfsSecondaryStorageResource] 
(AgentRequest-Handler-4:[]) 
   Execution of process [2779] for command [mount -t nfs -o 
soft,timeo=133,retrans=2147483647,tcp,acdirmax=0,acdirmin=0,vers=null 
10.0.32.4:/acs/secondary/.../sec5 
/mnt/SecStorage/aa3d83d6-fc81-367f-a76e-9f5de701b466 ] failed.
   ```
   
   ### Mount fails with parsing error
   ```
   2026-01-13T19:57:07,869 WARN [storage.resource.NfsSecondaryStorageResource] 
(AgentRequest-Handler-4:[]) 
   Process [2779] for command [...vers=null...] encountered the error: 
[mount.nfs: parsing error on 'vers=' option].
   ```
   
   ### Stack trace shows the bug location
   ```
   2026-01-13T19:57:07,877 ERROR [storage.resource.NfsSecondaryStorageResource] 
(AgentRequest-Handler-4:[]) GetRootDir for 
nfs://10.0.32.4/acs/secondary/ref-trl-10584-k-Mol9-rositsa-kyuchukova/ref-trl-10584-k-Mol9-rositsa-kyuchukova-sec5
 failed due to com.cloud.utils.exception.CloudRuntimeException: Unable to mount 
10.0.32.4:/acs/secondary/ref-trl-10584-k-Mol9-rositsa-kyuchukova/ref-trl-10584-k-Mol9-rositsa-kyuchukova-sec5
 at /mnt/SecStorage/aa3d83d6-fc81-367f-a76e-9f5de701b466 due to mount.nfs: 
parsing error on 'vers=' option 
com.cloud.utils.exception.CloudRuntimeException: Unable to mount 
10.0.32.4:/acs/secondary/ref-trl-10584-k-Mol9-rositsa-kyuchukova/ref-trl-10584-k-Mol9-rositsa-kyuchukova-sec5
 at /mnt/SecStorage/aa3d83d6-fc81-367f-a76e-9f5de701b466 due to mount.nfs: 
parsing error on 'vers=' option
        at 
org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.attemptMount(NfsSecondaryStorageResource.java:3095)
        at 
org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.mount(NfsSecondaryStorageResource.java:3046)
        at 
org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.mountUri(NfsSecondaryStorageResource.java:3034)
        at 
org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.getDir(NfsSecondaryStorageResource.java:2656)
        at 
org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.copyFromNfsToNfs(NfsSecondaryStorageResource.java:1388)
        at 
org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.execute(NfsSecondaryStorageResource.java:1152)
        at 
org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.executeRequest(NfsSecondaryStorageResource.java:320)
   
   ```
   
   ### Root Cause
   The issue is in `NfsSecondaryStorageResource.attemptMount()` at line 3095. 
When `nfsVersion` is null, the code should omit the `vers=` option entirely, 
but instead it converts null to the string "null" and appends `vers=null` to 
the mount options.
   
   I've found this PR https://github.com/apache/cloudstack/pull/9559 which 
fixed `nfsVersion` handling in some code paths:
   - `SystemVmTemplateRegistration.java`
   - `StorageManagerImpl.java`  
   - `DiagnosticsServiceImpl.java`
   
   However, the fix missed the SSVM code in 
NfsSecondaryStorageResource.attemptMount() which is called whenever the SSVM 
needs to mount any NFS secondary storage.
   I've also confirmed this bug is NOT related to any new feature - it 
reproduces when adding secondary storage with 
copytemplatesfromothersecondarystorages=false:
   
   ```
   2026-01-14 06:23:01,023 DEBUG [c.c.a.ApiServlet] 
(qtp2038105753-1531:[ctx-16d1d481]) (logid:7cabca9a) ===START===  10.0.3.251 -- 
GET  
name=sec6&url=nfs:%2F%2F10.0.32.4%2Facs%2Fsecondary%2Fref-trl-10584-k-Mol9-rositsa-kyuchukova%2Fref-trl-10584-k-Mol9-rositsa-kyuchukova-sec6&provider=NFS&zoneid=4afe198a-1f07-4535-91bf-b5708a58d8e7&details[0].key=copytemplatesfromothersecondarystorages&details[0].value=false&command=addImageStore&response=json&sessionkey=71oJXxW_ukmijOWzNlHmKi-W0_U
   ```
   
   This affects basic secondary storage operations on all fresh CloudStack 
installations.
   


-- 
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]

Reply via email to