Skip to content

Conversation

@abh1sar
Copy link
Collaborator

@abh1sar abh1sar commented Jan 16, 2026

Description

This PR fixes #12415

The agent.properties contains "nfsVersion = null" if the global settings secstorage.nfs.version is not set.
NfsSecondaryStorageResource picks up the nfsVersion as "null" String in CopyCommand and some other commands, and tries to mount the secondary storage with vers=null option leading to mount failures in logs.

Screenshot 2026-01-16 at 12 40 19 PM

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?

@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.23%. Comparing base (f1f779a) to head (050e0ed).
⚠️ Report is 1 commits behind head on 4.20.

Files with missing lines Patch % Lines
.../secondarystorage/SecondaryStorageManagerImpl.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #12445   +/-   ##
=========================================
  Coverage     16.23%   16.23%           
- Complexity    13381    13382    +1     
=========================================
  Files          5657     5657           
  Lines        499024   499025    +1     
  Branches      60562    60562           
=========================================
+ Hits          81029    81033    +4     
+ Misses       408959   408957    -2     
+ Partials       9036     9035    -1     
Flag Coverage Δ
uitests 4.03% <ø> (ø)
unittests 17.09% <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.

@abh1sar
Copy link
Collaborator Author

abh1sar commented Jan 16, 2026

@blueorangutan package

@blueorangutan
Copy link

@abh1sar a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

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

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

@abh1sar , this looks good, but you mention, "in CopyCommand and some other commands”. Does this mean this construct needs to be applied in several locations? (and hence methodised)

@abh1sar
Copy link
Collaborator Author

abh1sar commented Jan 16, 2026

@abh1sar , this looks good, but you mention, "in CopyCommand and some other commands”. Does this mean this construct needs to be applied in several locations? (and hence methodised)

All the commands take the value from the same place.

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 fixes a bug where the string literal "null" is written to the SSVM agent.properties file when the global setting secstorage.nfs.version is not configured. This causes NFS mount failures in the secondary storage VM because it attempts to mount with vers=null option.

Changes:

  • Added a null check before appending nfsVersion to boot arguments in finalizeVirtualMachineProfile method
Comments suppressed due to low confidence (1)

services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java:333

  • The same issue exists here where nfsVersion could be the string literal 'null' when secstorage.nfs.version is not configured. Consider adding a null check similar to the fix applied in finalizeVirtualMachineProfile (lines 1228-1230) to prevent setting null values on the command. This would be: if (nfsVersion != null) { setupCmd.setNfsVersion(nfsVersion); }
                String nfsVersion = imageStoreDetailsUtil.getNfsVersion(ssStore.getId());
                setupCmd.setNfsVersion(nfsVersion);

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

@DaanHoogland
Copy link
Contributor

@abh1sar , this looks good, but you mention, "in CopyCommand and some other commands”. Does this mean this construct needs to be applied in several locations? (and hence methodised)

All the commands take the value from the same place.

meaning they all pass through this big ass finalizeVirtualMachineProfile() right? in that case 👍 .

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

clgtm, (of course this method needs chopping up.)

@abh1sar
Copy link
Collaborator Author

abh1sar commented Jan 16, 2026

@abh1sar , this looks good, but you mention, "in CopyCommand and some other commands”. Does this mean this construct needs to be applied in several locations? (and hence methodised)

All the commands take the value from the same place.

meaning they all pass through this big ass finalizeVirtualMachineProfile() right? in that case 👍 .

Yes, they all read the value of nfsVersion from agent.properties which is set via finalizeVirtualMachineProfile()

@DaanHoogland
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

Copy link
Collaborator

@RosiKyu RosiKyu left a comment

Choose a reason for hiding this comment

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

LGTM

Fixes: #12415 - secstorage.nfs.version = NULL results in vers=null mount option and SSVM NFS mount failure


Pre-Test Configuration

Confirmed secstorage.nfs.version is NULL (the bug trigger condition):

mysql> SELECT name, value FROM configuration WHERE name='secstorage.nfs.version';
+------------------------+-------+
| name                   | value |
+------------------------+-------+
| secstorage.nfs.version | NULL  |
+------------------------+-------+
1 row in set (0.00 sec)

Test 1: Verify nfsVersion Not in SSVM Boot Arguments

root@s-1-VM:~# cat /var/cache/cloud/cmdline | tr ' ' '\n' | grep -i nfs
root@s-1-VM:~# 

root@s-1-VM:~# grep -i nfsversion /etc/cloudstack/agent/agent.properties
grep: /etc/cloudstack/agent/agent.properties: No such file or directory

Result: PASS - nfsVersion parameter is ABSENT from boot arguments (not nfsVersion=null)


Test 2: Verify Existing NFS Mounts Working

root@s-1-VM:~# mount | grep nfs
10.0.32.4:/acs/secondary/ref-trl-10637-k-Mol9-rositsa-kyuchukova/ref-trl-10637-k-Mol9-rositsa-kyuchukova-sec1 on /mnt/SecStorage/db6cac5e-bd12-3be8-ad93-324d1bd6a5a9 type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,acdirmin=0,acdirmax=0,soft,proto=tcp,timeo=133,retrans=2147483647,sec=sys,clientaddr=10.0.37.116,local_lock=none,addr=10.0.32.4)
10.0.32.4:/acs/secondary/ref-trl-10637-k-Mol9-rositsa-kyuchukova/ref-trl-10637-k-Mol9-rositsa-kyuchukova-sec2 on /mnt/SecStorage/41c5fac8-5833-3769-a25b-d326c94bf416 type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,acdirmin=0,acdirmax=0,soft,proto=tcp,timeo=133,retrans=2147483647,sec=sys,clientaddr=10.0.37.116,local_lock=none,addr=10.0.32.4)

Result: PASS - Both sec1 and sec2 mounted successfully with auto-negotiated vers=4.2


Test 3: Verify No vers=null Errors in Logs

root@s-1-VM:~# grep -i "vers=null" /var/log/cloud.log
root@s-1-VM:~#

Result: PASS - No vers=null mount errors found in SSVM logs


Test 4: Add New Secondary Storage (Critical Test)

Added new secondary storage sec3. This is the operation that failed in the bug report.

root@s-1-VM:~# mount | grep sec3
10.0.32.4:/acs/secondary/ref-trl-10637-k-Mol9-rositsa-kyuchukova/ref-trl-10637-k-Mol9-rositsa-kyuchukova-sec3 on /mnt/SecStorage/809fc3bc-3a29-335e-ac0d-eb1acc7551bb type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,acdirmin=0,acdirmax=0,soft,proto=tcp,timeo=133,retrans=2147483647,sec=sys,clientaddr=10.0.37.116,local_lock=none,addr=10.0.32.4)

Result: PASS - sec3 mounted successfully with auto-negotiated vers=4.2, NO vers=null error


Test 5: Verify Template Copy Operations

[root@mgmt1 ~]# tail -500 /var/log/cloudstack/management/management-server.log | grep -i "sec3"
2026-01-18 07:40:34,984 INFO  [o.a.c.s.i.TemplateServiceImpl] (pool-378-thread-2:[]) (logid:793cfd5b) Copied template [routing-3] to image store [sec3].
2026-01-18 07:40:51,369 INFO  [o.a.c.s.i.TemplateServiceImpl] (pool-378-thread-1:[]) (logid:793cfd5b) Copied template [centos55-x86_64] to image store [sec3].
2026-01-18 07:41:11,790 DEBUG [c.c.s.StatsCollector] (secstorage-1:[ctx-7ae0f021]) (logid:a61f3242) Verifying image storage [ImageStore {"id":3,"name":"sec3","uuid":"60472c35-d821-46cb-a5cc-7c94abbb6da8"}]. Capacity: total=[2.6357 TB], used=[1.5384 TB], threshold=[95.00%].

Result: PASS - Templates copied successfully to new secondary storage


Test 6: Verify SSVM Initialization

root@s-1-VM:~# journalctl -u cloud --no-pager | tail -5
Jan 18 07:40:28 s-1-VM _run.sh[3439]: 07:40:28,384  INFO NfsSecondaryStorageResource:3168 - Determined host 10.0.32.4 corresponds to IP 10.0.32.4
Jan 18 07:40:28 s-1-VM _run.sh[3439]: 07:40:28,685  INFO NfsSecondaryStorageResource:3232 - snapshots directory created/exists on Secondary Storage.
Jan 18 07:40:28 s-1-VM _run.sh[3439]: 07:40:28,689  INFO NfsSecondaryStorageResource:3232 - volumes directory created/exists on Secondary Storage.
Jan 18 07:40:49 s-1-VM _run.sh[3439]: 07:40:49,349  INFO NfsSecondaryStorageResource:3168 - Determined host 10.0.32.4 corresponds to IP 10.0.32.4

Result: PASS - Secondary storage initialized successfully, required directories created


Summary

Test Result
Existing NFS mounts (sec1, sec2) PASS - vers=4.2
Add new secondary storage (sec3) PASS - vers=4.2
Template copy to sec3 PASS
SSVM initialization PASS

Conclusion

LGTM

The fix correctly omits the nfsVersion parameter from SSVM boot arguments when secstorage.nfs.version is NULL, allowing the OS to auto-negotiate the NFS version instead of failing with mount.nfs: parsing error on 'vers=' option.

@abh1sar
Copy link
Collaborator Author

abh1sar commented Jan 18, 2026

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-15203)

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.

5 participants