Cloudstack doesn't validate the nfs secondary storage mount point
- Langage dominant
- Java
- Étoiles
- 3.1k
- Forks
- 1.4k
- Merge moyen
- 6 j 19 h
- PR mergées (30 j)
- 32
Description
### problem
Cloudstack doesn't validate the secondary storage
### versions
ACS 4.22
### The steps to reproduce the bug
1. Have a cloudstack environment
2. Add a secondary storage
Provide an incorrect nfs mount point
3. Cloudstack adds secondary storage successfully even though there is an exception in logs
```
2026-02-20 11:28:49,044 DEBUG [c.c.u.SystemVmTemplateRegistration] (qtp1390913202-17:[ctx-c6004122, ctx-953c673e]) (logid:fd82bd2b) Successfully executed process [29541] for command [/usr/share/cloudstack-common/scripts/storage/secondary/setup-sysvm-tmplt -u 379d95ca-ae32-448b-821e-1f69ac0c0ae9 -f /usr/share/cloudstack-management/templates/systemvm/systemvmtemplate-4.22.0-x86_64-kvm.qcow2.bz2 -h kvm -d /tmp/tmp15364234521465452733/template/tmpl/1/3 ].
2026-02-20 11:28:49,044 DEBUG [c.c.u.SystemVmTemplateRegistration] (qtp1390913202-17:[ctx-c6004122, ctx-953c673e]) (logid:fd82bd2b) + [[ ! -u 379d95ca-ae32-448b-821e-1f69ac0c0ae9 -f /usr/share/cloudstack-management/templates/systemvm/systemvmtemplate-4.22.0-x86_64-kvm.qcow2.bz2 -h kvm -d /tmp/tmp15364234521465452733/template/tmpl/1/3 =~ ^-.+ ]]
+ OPTERR=0
+ DISKSPACE=2120000
+ getopts h:f:d:u::# OPTION
+ case $OPTION in
+ uflag=1
+ uuid=379d95ca-ae32-448b-821e-1f69ac0c0ae9
+ getopts h:f:d:u::# OPTION
+ case $OPTION in
+ fflag=1
+ tmpltimg=/usr/share/cloudstack-management/templates/systemvm/systemvmtemplate-4.22.0-x86_64-kvm.qcow2.bz2
+ getopts h:f:d:u::# OPTION
+ case $OPTION in
+ hyper=kvm
+ getopts h:f:d:u::# OPTION
+ case $OPTION in
+ destdir=/tmp/tmp15364234521465452733/template/tmpl/1/3
+ getopts h:f:d:u::# OPTION
+ [[ kvm == \k\v\m ]]
+ ext=qcow2
++ which qemu-img
+ qemuimgcmd=/usr/bin/qemu-img
+ localfile=379d95ca-ae32-448b-821e-1f69ac0c0ae9.qcow2
+ sudo mkdir -p /tmp/tmp15364234521465452733/template/tmpl/1/3
+ [[ 0 -ne 0 ]]
+ [[ -f /tmp/tmp15364234521465452733/template/tmpl/1/3/template.properties ]]
++ sudo find /tmp/tmp15364234521465452733/template/tmpl/1/3 -name '*.qcow2'
+ destfiles=
+ sudo cp /usr/share/cloudstack-management/templates/systemvm/systemvmtemplate-4.22.0-x86_64-kvm.qcow2.bz2 /tmp/cloud/templates//379d95ca-ae32-448b-821e-1f69ac0c0ae9.qcow2
+ [[ 0 -ne 0 ]]
+++ dirname /usr/share/cloudstack-common/scripts/storage/secondary/setup-sysvm-tmplt
++ /usr/share/cloudstack-common/scripts/storage/secondary/createtmplt.sh -s 2 -d 'SystemVM Template ( kvm )' -n 379d95ca-ae32-448b-821e-1f69ac0c0ae9.qcow2 -t /tmp/tmp15364234521465452733/template/tmpl/1/3/ -f /tmp/cloud/templates//379d95ca-ae32-448b-821e-1f69ac0c0ae9.qcow2 -u -v -c
Uncompressing to /tmp/cloud/templates//379d95ca-ae32-448b-821e-1f69ac0c0ae9.qcow2.tmp (type bz2)...could take a long time
Copying to /tmp/tmp15364234521465452733/template/tmpl/1/3//379d95ca-ae32-448b-821e-1f69ac0c0ae9.qcow2...could take a while
+ installrslt=
+ [[ 0 -ne 0 ]]
+ tmpdestdir=/tmp/cloud/templates/
+ '[' qcow2 == ova ']'
+ rm -rf /tmp/cloud/templates//379d95ca-ae32-448b-821e-1f69ac0c0ae9.qcow2.tmp
+ tmpltfile=/tmp/tmp15364234521465452733/template/tmpl/1/3/379d95ca-ae32-448b-821e-1f69ac0c0ae9.qcow2
++ awk '-F ' '{print $5}'
++ sudo ls -l /tmp/tmp15364234521465452733/template/tmpl/1/3/379d95ca-ae32-448b-821e-1f69ac0c0ae9.qcow2
+ tmpltsize=522649088
+ [[ qcow2 == \q\c\o\w\2 ]]
++ xargs
++ grep -i 'virtual size'
++ sudo /usr/bin/qemu-img info /tmp/tmp15364234521465452733/template/tmpl/1/3/379d95ca-ae32-448b-821e-1f69ac0c0ae9.qcow2
++ sed -ne 's/.*(\([0-9]*\).*/\1/p'
+ vrtmpltsize=5242880000
+ templateId=3
+ sudo touch /tmp/tmp15364234521465452733/template/tmpl/1/3/template.properties
+ echo qcow2=true
+ echo id=3
+ echo public=true
+ echo qcow2.filename=379d95ca-ae32-448b-821e-1f69ac0c0ae9.qcow2
+ echo uniquename=routing-3
+ echo qcow2.virtualsize=5242880000
+ echo virtualsize=5242880000
+ echo qcow2.size=522649088
+ sudo cp /tmp/cloud/templates//template.properties /tmp/tmp15364234521465452733/template/tmpl/1/3/template.properties
+ '[' -f /tmp/cloud/templates//template.properties ']'
Successfully installed system VM template /usr/share/cloudstack-management/templates/systemvm/systemvmtemplate-4.22.0-x86_64-kvm.qcow2.bz2 and template.properties to /tmp/tmp15364234521465452733/template/tmpl/1/3
+ exit 0
2026-02-20 11:28:49,067 DEBUG [c.c.u.s.Script] (qtp1390913202-17:[ctx-c6004122, ctx-953c673e]) (logid:fd82bd2b) Executing command [/bin/bash -c sudo umount /tmp/tmp15364234521465452733 ].
2026-02-20 11:28:49,097 WARN [c.c.u.s.Script] (qtp1390913202-17:[ctx-c6004122, ctx-953c673e]) (logid:fd82bd2b) Execution of process [29663] for command [/bin/bash -c sudo umount /tmp/tmp15364234521465452733 ] failed.
2026-02-20 11:28:49,097 DEBUG [c.c.u.s.Script] (qtp1390913202-17:[ctx-c6004122, ctx-953c673e]) (logid:fd82bd2b) Exit value of process [29663] for command [/bin/bash -c sudo umount /tmp/tmp15364234521465452733 ] is [32].
2026-02-20 11:28:49,097 WARN [c.c.u.s.Script] (qtp1390913202-17:[ctx-c6004122, ctx-953c673e]) (logid:fd82bd2b) Process [29663] for command [/bin/bash -c sudo umount /tmp/tmp15364234521465452733 ] encountered the error: [umount: /tmp/tmp15364234521465452733: not mounted.].
2026-02-20 11:28:49,098 ERROR [c.c.u.SystemVmTemplateRegistration] (qtp1390913202-17:[ctx-c6004122, ctx-953c673e]) (logid:fd82bd2b) Failed to cleanup mounted store at: /tmp/tmp15364234521465452733 java.nio.file.DirectoryNotEmptyException: /tmp/tmp15364234521465452733
at java.base/sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:246)
at java.base/sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:110)
at java.base/java.nio.file.Files.deleteIfExists(Files.java:1191)
at com.cloud.upgrade.SystemVmTemplateRegistration.unmountStore(SystemVmTemplateRegistration.java:671)
at com.cloud.storage.StorageManagerImpl$4.doInTransactionWithoutResult(StorageManagerImpl.java:4070)
at com.cloud.utils.db.TransactionCallbackNoReturn.doInTransaction(TransactionCallbackNoReturn.java:25)
at com.cloud.utils.db.Transaction$2.doInTransaction(Transaction.java:48)
at com.cloud.utils.db.Transaction.execute(Transaction.java:38)
...
### What to do about it?
Cloudstack should throw an exception saying the nfs mount is an invalid
Cloudstack is doing the validation only when adding primary storage
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par le flux d’ajout de stockage secondaire et le chemin de nettoyage présenté dans SystemVmTemplateRegistration.java et StorageManagerImpl.java. Reproduisez le problème avec un point de montage NFS invalide, puis cherchez pourquoi l’échec du montage ne rejette pas le stockage. Le travail est terminé lorsque l’opération d’ajout lève une invalid-mount exception et dispose d’une couverture de régression pour cet échec.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java
- Domaine
- infrastructure
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 45/100