Skip to content

Fix NPE in NASBackupProvider when no running KVM host is available#12805

Open
jmsperu wants to merge 1 commit intoapache:4.22from
jmsperu:fix/nas-backup-null-host-npe
Open

Fix NPE in NASBackupProvider when no running KVM host is available#12805
jmsperu wants to merge 1 commit intoapache:4.22from
jmsperu:fix/nas-backup-null-host-npe

Conversation

@jmsperu
Copy link

@jmsperu jmsperu commented Mar 12, 2026

Rebased onto 4.22 as requested (previously #12680).

ResourceManager.findOneRandomRunningHostByHypervisor() can return null when no KVM host in the zone has status=Up (e.g. during management server startup, brief agent disconnections, or host state transitions).

NASBackupProvider.syncBackupStorageStats() and deleteBackup() call host.getId() without a null check, causing a NullPointerException that crashes the entire BackupSyncTask background job every sync interval.

This adds null checks in both methods:

  • syncBackupStorageStats: log a warning and return early
  • deleteBackup: throw CloudRuntimeException with a descriptive message

ResourceManager.findOneRandomRunningHostByHypervisor() can return null
when no KVM host in the zone has status=Up (e.g. during management
server startup, brief agent disconnections, or host state transitions).

NASBackupProvider.syncBackupStorageStats() and deleteBackup() call
host.getId() without a null check, causing a NullPointerException that
crashes the entire BackupSyncTask background job every sync interval.

This adds null checks in both methods:
- syncBackupStorageStats: log a warning and return early
- deleteBackup: throw CloudRuntimeException with a descriptive message
@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.

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 3.70%. Comparing base (27bce46) to head (30b707c).

❗ There is a different number of reports uploaded between BASE (27bce46) and HEAD (30b707c). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (27bce46) HEAD (30b707c)
unittests 1 0
Additional details and impacted files
@@              Coverage Diff              @@
##               4.22   #12805       +/-   ##
=============================================
- Coverage     17.61%    3.70%   -13.91%     
=============================================
  Files          5917      448     -5469     
  Lines        531415    38028   -493387     
  Branches      64973     7036    -57937     
=============================================
- Hits          93588     1409    -92179     
+ Misses       427271    36432   -390839     
+ Partials      10556      187    -10369     
Flag Coverage Δ
uitests 3.70% <ø> (ø)
unittests ?

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.

@blueorangutan
Copy link

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 17121

@DaanHoogland
Copy link
Contributor

@jmsperu , probably due to the rebase:

20:18:12 [ERROR] /jenkins/workspace/acs-centos8-pkg-builder/dist/rpmbuild/BUILD/cloudstack-4.22.1.0-SNAPSHOT/plugins/backup/nas/src/main/java/org/apache/cloudstack/backup/NASBackupProvider.java:[558,12] error: cannot find symbol
20:18:12   symbol:   variable CollectionUtils
20:18:12   location: class NASBackupProvider

seems an import is missing.

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.

3 participants