Skip to content

nasbackup: fix backup stopped vm on Ubuntu 26.04#13643

Open
weizhouapache wants to merge 1 commit into
apache:mainfrom
weizhouapache:4.23-nasbackup-ubuntu26
Open

nasbackup: fix backup stopped vm on Ubuntu 26.04#13643
weizhouapache wants to merge 1 commit into
apache:mainfrom
weizhouapache:4.23-nasbackup-ubuntu26

Conversation

@weizhouapache

Copy link
Copy Markdown
Member

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

Description

This PR...

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

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
```
Copilot AI review requested due to automatic review settings July 17, 2026 12:55
@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}' with find ... -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.

@weizhouapache weizhouapache added this to the 4.23.0 milestone Jul 17, 2026
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 19.64%. Comparing base (75748a5) to head (7c2b919).

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     
Flag Coverage Δ
uitests 3.41% <ø> (ø)
unittests 20.92% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18604

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan test ubuntu26 kvm-ubuntu26

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Trillian-Jenkins test job (ubuntu26 mgmt + kvm-ubuntu26) has been kicked to run smoke tests

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan test ubuntu24 kvm-ubuntu24

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Trillian-Jenkins test job (ubuntu24 mgmt + kvm-ubuntu24) has been kicked to run smoke tests

@winterhazel winterhazel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
13674

Edit: 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?

@winterhazel
winterhazel self-requested a review July 17, 2026 15:48
@weizhouapache

Copy link
Copy Markdown
Member Author

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
13674

Edit: 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
In my testing, the directory has only 1 qcow2 file. I will double check when possible (I will on leave next week)

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-8)
Environment: kvm-ubuntu26 (x2), zone: Advanced Networking with Mgmt server u26
Total time taken: 55415 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13643-n8-kvm-ubuntu26.zip
Smoke tests completed. 156 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-16585)
Environment: kvm-ubuntu24 (x2), zone: Advanced Networking with Mgmt server u24
Total time taken: 58370 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13643-t16585-kvm-ubuntu24.zip
Smoke tests completed. 156 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

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.

4 participants