CreateSharedFileSystem NPE ("template is null") when zone has mixed hypervisor types
関連するプルリクエストがすでにマージされています。
- #13830 @Dogface2k による — マージ済み
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- java
調査の方向性
まずマージ済みの pull request #13830 を確認し、次に plugins/storage/sharedfs/storagevm/src/main/java/org/apache/cloudstack/storage/sharedfs/lifecycle/StorageVmSharedFSLifeCycle.java の deploySharedFSVM を調査します。異なるハイパーバイザー種別を混在させて createSharedFileSystem を再現し、テンプレートがない場合でも NPE が発生しなくなり、有効な system VM テンプレートを選択できることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Bug: CreateSharedFileSystem throws NPE ("template is null") when a zone has more than one hypervisor type
Component: plugins/storage/sharedfs/storagevm/src/main/java/org/apache/cloudstack/storage/sharedfs/lifecycle/StorageVmSharedFSLifeCycle.java
Affected versions: 4.22.1.0 (confirmed present on main as of 2026-08-06 — same code, unrelated to the two unrelated API-signature diffs between main and 4.22.1.0 in this file)
Summary
createSharedFileSystem fails immediately with:
java.lang.NullPointerException: Cannot invoke "com.cloud.storage.VMTemplateVO.getId()" because "template" is null
on any zone that has more than one hypervisor type, where at least one of those hypervisor types has no system VM template available (e.g. an External/MaaS cluster alongside a KVM cluster in the same zone).
Root cause
In deploySharedFSVM():
List<Hypervisor.HypervisorType> hypervisors = resourceMgr.getSupportedHypervisorTypes(zoneId, false, null);
if (hypervisors.size() > 0) {
Collections.shuffle(hypervisors);
} ...
for (final Iterator<Hypervisor.HypervisorType> iter = hypervisors.iterator(); iter.hasNext();) {
final Hypervisor.HypervisorType hypervisor = iter.next();
VMTemplateVO template = templateDao.findSystemVMReadyTemplate(zoneId, hypervisor, preferredArchitecture);
if (template == null && !iter.hasNext()) {
throw new CloudRuntimeException(...);
}
LaunchPermissionVO existingPermission = launchPermissionDao.findByTemplateAndAccount(template.getId(), owner.getId());
...
The hypervisor list is shuffled, and the null-check only throws when the current hypervisor is the last one in the iteration (!iter.hasNext()). If template is null for a hypervisor that is not last in the (randomized) order — e.g. External, which has no CloudStack system VM template by design — the code falls through to template.getId() on the same iteration instead of continue-ing to the next hypervisor. This crashes before ever reaching a hypervisor (e.g. KVM) that does have a valid, Ready system VM template.
Because the list is shuffled, this is intermittent: the call succeeds whenever the working hypervisor happens to be drawn first, and fails whenever a hypervisor with no system VM template is drawn first with more entries still pending.
Reproduction
- Zone with two clusters of different hypervisor types, one of which has no system VM template registered (e.g.
KVM+External/MaaS). - Call
createSharedFileSystemrepeatedly. - Observe intermittent NPE vs. success depending on shuffle order, even though the working hypervisor's system VM template is verified
Active/Ready/ fully downloaded in the DB (vm_template,template_zone_ref,template_store_ref).
Impact
Any deployment mixing hypervisor types within one zone (common with hybrid KVM + MaaS/External or KVM + VMware setups) can hit this nondeterministically for every Shared FileSystem creation attempt, with no workaround short of isolating hypervisor types into separate zones.
- 主要言語
- Java
- スター
- 3.1k
- フォーク
- 1.4k
- 平均マージ
- 6日 20時間
- マージ済み PR(30日)
- 27
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/cloudstack のほかの issue
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
apache/cloudstack#14222 ·
-
bug component:kubernetes
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
apache/cloudstack#14180 ·
-
bug component:projects component:UI
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
apache/cloudstack#14070 · コメント 5 件 ·
-
component:backup
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
apache/cloudstack#14013 ·
-
KVM agent fails to connect to Ceph RBD storage pool after upgrading Ceph client to Tentacle 20.2.4 オープンbug component:ceph
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/cloudstack#13989 · コメント 3 件 ·
apache/cloudstack の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
elastic/gradle-plugins#157 ·
-
enhancement Tools
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
apache/rocketmq-dashboard#5008 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
DETECT_PARAMETER_NAMES=false silently disables @ConstructorProperties-based Creator detection too オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
FasterXML/jackson-databind#6229 ·