Uh oh!
There was an error while loading. Please reload this page.
nasbackup: fix backup stopped vm on Ubuntu 26.04 - #13643
Conversation
backing up stopped vm failed on Ubuntu 26.04 failed with error
```
2026-07-17 09:47:56,636 DEBUG [resource.wrapper.LibvirtTakeBackupCommandWrapper] (AgentRequest-Handler-4:[]) (logid:fd553fbe) Wei Parsing backup size line: Jul
2026-07-17 09:47:56,636 WARN [cloud.agent.Agent] (AgentRequest-Handler-4:[]) (logid:fd553fbe) Caught: java.lang.NumberFormatException: For input string: "Jul"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
at java.base/java.lang.Long.parseLong(Long.java:711)
at java.base/java.lang.Long.parseLong(Long.java:836)
at com.cloud.hypervisor.kvm.resource.wrapper.LibvirtTakeBackupCommandWrapper.parseBackupSize(LibvirtTakeBackupCommandWrapper.java:230)
at com.cloud.hypervisor.kvm.resource.wrapper.LibvirtTakeBackupCommandWrapper.execute(LibvirtTakeBackupCommandWrapper.java:111)
at com.cloud.hypervisor.kvm.resource.wrapper.LibvirtTakeBackupCommandWrapper.execute(LibvirtTakeBackupCommandWrapper.java:42)
at com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper.execute(LibvirtRequestWrapper.java:78)
at com.cloud.hypervisor.kvm.resource.LibvirtComputingResource.executeRequest(LibvirtComputingResource.java:2407)
```
it is due to different format of "ls -l" command:
```
kvm1:~# ls -l /tmp/csbackup.2CsWP/i-2-582-VM/2026.07.17.09.47.45/
total 1475240
-rw-r--r--+1 root root 1510539264 Jul 17 10:07 root.49d59058-90ce-4fba-bee6-da6d626065dd.qcow2
kvm1:~# ls -l --numeric-uid-gid /tmp/csbackup.2CsWP/i-2-582-VM/2026.07.17.09.47.45/ | awk '{print $5}'
Jul
kvm1:~# find /tmp/csbackup.2CsWP/i-2-582-VM/2026.07.17.09.47.45/ -type f -exec stat -c '%s' {} +
1510539264
```weizhouapache
commented
Jul 17, 2026
@blueorangutan package |
blueorangutan
commented
Jul 17, 2026
@weizhouapache 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. |
There was a problem hiding this comment.
Pull request overview
Fixes NAS backup of stopped KVM VMs on Ubuntu 26.04 by avoiding ls -l output parsing (which can shift fields) when reporting backup size back to the management server.
Changes:
- Replace
ls -l --numeric-uid-gid ... | awk '{print $5}'withfind ... -exec stat -c '%s' ...to emit byte sizes reliably for the produced backup files.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@## main #13643 +/- ##
============================================
- Coverage 19.65% 19.64% -0.01% + Complexity 19792 19785 -7
============================================
Files 6368 6368 Lines 575107 575107 Branches 70370 70370 ============================================
- Hits 113016 112986 -30 - Misses 449808 449836 +28 - Partials 12283 12285 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
blueorangutan
commented
Jul 17, 2026
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18604 |
weizhouapache
commented
Jul 17, 2026
@blueorangutan test ubuntu26 kvm-ubuntu26 |
blueorangutan
commented
Jul 17, 2026
@weizhouapache a [SL] Trillian-Jenkins test job (ubuntu26 mgmt + kvm-ubuntu26) has been kicked to run smoke tests |
weizhouapache
commented
Jul 17, 2026
@blueorangutan test ubuntu24 kvm-ubuntu24 |
blueorangutan
commented
Jul 17, 2026
@weizhouapache a [SL] Trillian-Jenkins test job (ubuntu24 mgmt + kvm-ubuntu24) has been kicked to run smoke tests |
There was a problem hiding this comment.
Assuming that the file output order does not matter, it looks good (did not test).
fabricio@pc:~/github/cloudstack$ ls -l --numeric-uid-gid $dest| awk '{print $5}'
4978
9819
13674
205830
4954
fabricio@pc:~/github/cloudstack$ find "$dest" -type f -exec stat -c '%s' {} +
4954
9819
4978
205830
13674Edit: I had a look at the code that parses this output. It seems to assume that the volume's size will be on the last line when backing up a single volume?
privatelongparseBackupSize(Stringstdout, List<String> diskPaths) {
longbackupSize = 0L;
if (CollectionUtils.isNullOrEmpty(diskPaths)) {
List<String> outputLines = Arrays.asList(stdout.split("\n"));
if (!outputLines.isEmpty()) {
backupSize = Long.parseLong(outputLines.get(outputLines.size() - 1).trim());
}
} else {
for (Stringline : stdout.split("\n")) {
backupSize = backupSize + Long.parseLong(line.split(" ")[0].trim());
}
}
returnbackupSize;
}@weizhouapache could you check if this output order change may cause a regression?
weizhouapache
commented
Jul 17, 2026
Thanks @winterhazel for checking |
blueorangutan
commented
Jul 18, 2026
[SF] Trillian test result (tid-8)
|
blueorangutan
commented
Jul 18, 2026
[SF] Trillian test result (tid-16585)
|
winterhazel
commented
Jul 20, 2026
@abh1sar could you also have a look at this change, specially at the comment in #13643 (review)? I am not that familiar with how the NAS plugin works, so I would appreciate some other eyes here :) |
abh1sar
commented
Jul 20, 2026
Sure, I'll review and test tomorrow. |
abh1sar
commented
Jul 21, 2026
In case of a single volume vm there will be only one line, so order doesn't matter. |
abh1sar
left a comment
There was a problem hiding this comment.
Tested, LGTM.
p.s the bash script needs some refactoring. I'll raise a PR for it.
But this change good enough for 4.23
winterhazel
left a comment
There was a problem hiding this comment.
@abh1sar thank you. Merging this one.
Uh oh!
There was an error while loading. Please reload this page.
backing up stopped vm failed on Ubuntu 26.04 failed with error
it is due to different format of "ls -l" command:
Description
This PR...
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?