Cloudstack doesn't validate the nfs secondary storage mount point
- 主要语言
- Java
- 星标
- 3.1k
- 派生
- 1.4k
- 平均合并
- 6 天 19 小时
- 30 天内合并 PR
- 32
描述
### 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
贡献指南
调研方向
从 SystemVmTemplateRegistration.java 和 StorageManagerImpl.java 中显示的辅助存储添加流程和清理路径开始。使用无效的 NFS 挂载点重现该问题,然后跟踪挂载失败为何没有拒绝该存储。完成的标准是添加操作抛出 invalid-mount exception,并且针对该失败有回归测试覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- infrastructure
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100