You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "jmsperu (via GitHub)" <gi...@apache.org> on 2026/02/21 19:51:00 UTC
[PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
jmsperu opened a new pull request, #12680:
URL: https://github.com/apache/cloudstack/pull/12680
## Description
`NASBackupProvider.syncBackupStorageStats()` crashes with a `NullPointerException` when `ResourceManager.findOneRandomRunningHostByHypervisor()` returns `null`. This happens when no KVM host in the zone has `status=Up` at the moment the `BackupSyncTask` runs (e.g., during management server startup, brief agent disconnections, or host state transitions).
The NPE kills the entire `BackupSyncTask` background job every sync interval (default 300s), flooding the management server log with stack traces and preventing backup storage stats from being updated.
The same pattern exists in `deleteBackup()` where `host` can be null when the VM is removed and no running KVM host is available.
### Stack Trace
```
ERROR [o.a.c.b.B.BackupSyncTask] Error trying to run backup-sync background task due to:
[Cannot invoke "com.cloud.host.Host.getId()" because "host" is null].
java.lang.NullPointerException: Cannot invoke "com.cloud.host.Host.getId()" because "host" is null
at org.apache.cloudstack.backup.NASBackupProvider.syncBackupStorageStats(NASBackupProvider.java:544)
at org.apache.cloudstack.backup.BackupManagerImpl$BackupSyncTask.runInContext(BackupManagerImpl.java:1947)
```
## Changes
- `syncBackupStorageStats()`: Add early return with warning log when no running KVM host is found
- `deleteBackup()`: Add null check with descriptive `CloudRuntimeException`
## How Has This Been Tested
Tested on a production CloudStack 4.22.0.0 deployment with 3 KVM hosts and NAS (NFS) backup provider. Before the fix, the NPE fired every 5 minutes after management server restart. After applying the patch, the `BackupSyncTask` runs cleanly — logging a warning during startup and resuming normally once hosts reconnect.
## Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
## Screenshot / Video (if applicable)
Before (every 5 minutes):
```
ERROR [o.a.c.b.B.BackupSyncTask] Error trying to run backup-sync background task due to:
[Cannot invoke "com.cloud.host.Host.getId()" because "host" is null]
```
After:
```
WARN [o.a.c.b.NASBackupProvider] Unable to find a running KVM host in zone 1 to sync backup storage stats
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-3942582086
## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/12680?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 3.67%. Comparing base ([`30e6c22`](https://app.codecov.io/gh/apache/cloudstack/commit/30e6c224bdd2e33f35349e808ec75428853f2aa0?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`80435b4`](https://app.codecov.io/gh/apache/cloudstack/commit/80435b4f3f6bb4dc7f8ad61c098785c9b3530f5a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
> :exclamation: There is a different number of reports uploaded between BASE (30e6c22) and HEAD (80435b4). Click for more details.
>
> <details><summary>HEAD has 1 upload less than BASE</summary>
>
>| Flag | BASE (30e6c22) | HEAD (80435b4) |
>|------|------|------|
>|unittests|1|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #12680 +/- ##
=============================================
- Coverage 17.92% 3.67% -14.26%
=============================================
Files 5939 454 -5485
Lines 533181 38539 -494642
Branches 65237 7125 -58112
=============================================
- Hits 95585 1415 -94170
+ Misses 426856 36937 -389919
+ Partials 10740 187 -10553
```
| [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/12680/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/12680/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `3.67% <ø> (ø)` | |
| [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/12680/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/cloudstack/pull/12680?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-4039588848
@abh1sar
can you please review it ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-3957713724
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-3958682125
@blueorangutan test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "jmsperu (via GitHub)" <gi...@apache.org>.
jmsperu commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-4049208223
Rebased onto 4.22 and opened a new PR since the original couldn't be reopened after the base branch change: #12805
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "jmsperu (via GitHub)" <gi...@apache.org>.
jmsperu closed pull request #12680: Fix NPE in NASBackupProvider when no running KVM host is available
URL: https://github.com/apache/cloudstack/pull/12680
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#discussion_r2839039399
##########
plugins/backup/nas/src/main/java/org/apache/cloudstack/backup/NASBackupProvider.java:
##########
@@ -564,7 +567,14 @@ public Pair<Long, Long> getBackupStorageStats(Long zoneId) {
@Override
public void syncBackupStorageStats(Long zoneId) {
final List<BackupRepository> repositories = backupRepositoryDao.listByZoneAndProvider(zoneId, getName());
+ if (CollectionUtils.isEmpty(repositories)) {
+ return;
+ }
Review Comment:
The empty repositories check is placed after the method starts processing but before the host lookup. If repositories are empty, the host lookup at line 573 becomes unnecessary. Consider moving this check before the host lookup, or better yet, to the beginning of the method to avoid any unnecessary operations when there are no repositories to process.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "jmsperu (via GitHub)" <gi...@apache.org>.
jmsperu commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-4049045471
Hello, done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-3957722613
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-4049150749
> Hello, done.
hello @jmsperu , what do you mean done? did you rebase or is your issue gone? Is this PR no longer relevant?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-3939324455
Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
Here are some useful points:
- In case of a new feature add useful documentation (raise doc PR at https://github.com/apache/cloudstack-documentation)
- Be patient and persistent. It might take some time to get a review or get the final approval from the committers.
- Pay attention to the quality of your code, ensure tests are passing and your PR doesn't have conflicts.
- Please follow [ASF Code of Conduct](https://github.com/apache/.github/blob/main/.github/CODE_OF_CONDUCT.md) for all communication including (but not limited to) comments on Pull Requests, Issues, Mailing list and Slack.
- Be sure to read the [CloudStack Coding Conventions](https://cwiki.apache.org/confluence/display/CLOUDSTACK/Coding+conventions).
Apache CloudStack is a community-driven project and together we are making it better 🚀.
In case of doubts contact the developers at:
Mailing List: dev@cloudstack.apache.org (https://cloudstack.apache.org/mailing-lists.html)
Slack: https://apachecloudstack.slack.com/
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-3958688569
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-3945327889
@jmsperu , would you want this included in the next 22 release (in which case you might to want to base it of the 4.22 branch)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "abh1sar (via GitHub)" <gi...@apache.org>.
abh1sar commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-4043626135
@jmsperu Can you please rebase to 4.22?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-4049234092
> Rebased onto 4.22 and opened a new PR since the original couldn't be reopened after the base branch change: #12805
ok, thanks, that wouldn’t have been a problem @jmsperu .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-3958064752
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16940
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix NPE in NASBackupProvider when no running KVM host is available [cloudstack]
Posted by "jmsperu (via GitHub)" <gi...@apache.org>.
jmsperu commented on PR #12680:
URL: https://github.com/apache/cloudstack/pull/12680#issuecomment-3953457281
> @jmsperu , would you want this included in the next 22 release (in which case you might to want to base it of the 4.22 branch)
Hello, am good with int he next release.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org