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
```
|
@blueorangutan package |
|
@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:
|
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18604 |
|
@blueorangutan test ubuntu26 kvm-ubuntu26 |
|
@weizhouapache a [SL] Trillian-Jenkins test job (ubuntu26 mgmt + kvm-ubuntu26) has been kicked to run smoke tests |
|
@blueorangutan test ubuntu24 kvm-ubuntu24 |
|
@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?
private long parseBackupSize(String stdout, List<String> diskPaths) {
long backupSize = 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 (String line : stdout.split("\n")) {
backupSize = backupSize + Long.parseLong(line.split(" ")[0].trim());
}
}
return backupSize;
}@weizhouapache could you check if this output order change may cause a regression?
Thanks @winterhazel for checking |
|
[SF] Trillian test result (tid-8)
|
|
[SF] Trillian test result (tid-16585)
|
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?