apache / apache/cloudstack

Cloudstack doesn't validate the nfs secondary storage mount point

Aperta
#12,674 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
component:secondary-storage type:bug type:improvement
Lingua principale
Java
Stelle
3.1k
Fork
1.4k
Merge medio
6g 19h
PR unite (30g)
32

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con il flusso di aggiunta dello storage secondario e il percorso di pulizia mostrato in SystemVmTemplateRegistration.java e StorageManagerImpl.java. Riproduci il problema con un punto di mount NFS non valido, quindi traccia il motivo per cui il fallimento del mount non rifiuta lo storage. Il lavoro è completato quando l’operazione di aggiunta genera una invalid-mount exception e dispone di una copertura di regressione per il fallimento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
infrastructure
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.