Repository navigation
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
What changed in this PR
Updates VM disk image cloning to better track rsync copy progress (Fixes #20) by switching to rsync progress output captured in a log file and parsing it to compute cloning status.
Changes:
- Update the rsync invocation to include progress output and enable logging to a file.
- Add rsync-specific progress parsing logic in
clone_vm_hdd_image()and adjust timeout-loop behavior accordingly. - Update/add unit tests to cover rsync vs scp behavior and progress reporting.
| File | Description |
|---|---|
| mfd_kvm/hypervisor.py | Switch rsync command to emit progress, capture output to a log file, and parse progress status during the cloning loop. |
| tests/unit/test_mfd_kvm/test_hypervisor.py | Update expectations for the new rsync command/logging behavior and add tests for rsync vs scp “still cloning” progress messages. |
Review effort: Lite
| elif path_to_destination_image.name in last_line or "sending incremental file list" in last_line: | ||
| current_size = 0 | ||
| else: | ||
| current_size = last_line.strip().split()[0].replace(",", "") |
| copy_command = "rsync -av" if self._rsync_available else "scp" | ||
| params = f" --info=progress2 --outbuf=N " if self._rsync_available else " " | ||
| # show 5 column of ls, size of file | ||
| target_size = self._conn.execute_command( | ||
| f"ls {path_to_source_image} -l | awk '{{print $5}}'", | ||
| shell=True, | ||
| ).stdout | ||
| copy_process = self._conn.start_process( | ||
| f"{copy_command}{params}{path_to_source_image} {path_to_destination_image}", | ||
| log_file=self._rsync_available, | ||
| ) |
| out = self._conn.execute_command( | ||
| f"cat -A {copy_process.log_path}", | ||
| shell=True, | ||
| expected_return_codes={}, | ||
| skip_logging=True, | ||
| ) |
Fixes intel#20 Signed-off-by: Łukasz Kleina <lukaszx.kleina@intel.com>
bd2f0b8 to
5142a1f
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
7 open issues
last_line.strip().split()[0]can raiseIndexErrorif the parsed chunk is empty/whitespace… The FileNotFoundError message is grammatically awkward and not very actionable. Consider a clearer,… · New Reading the full rsync log viacat -Aon every polling interval can become increasingly expensive… · New The conditionpath_to_destination_image.name in last_lineis unlikely to match typical rsync… · New This method otherwise uses the moduleloggerfor logging, but progress logs are sent via the root… · New Reading the entire rsync log file every 30 seconds (cat -A) can become increasingly expensive on… The command composition relies onparamscontaining leading/trailing spaces and on implicit…
Review effort: Lite
| ) | ||
| return path_to_destination_image | ||
| if not path_to_source_image.is_file(): | ||
| raise FileNotFoundError(f"Not found {path_to_source_image} in system.") |
| out = self._conn.execute_command( | ||
| f"cat -A {copy_process.log_path}", | ||
| shell=True, | ||
| expected_return_codes={}, | ||
| skip_logging=True, | ||
| ) |
| elif path_to_destination_image.name in last_line or "sending incremental file list" in last_line: | ||
| current_size = 0 | ||
| else: | ||
| current_size = last_line.strip().split()[0].replace(",", "") |
| except (TypeError, ValueError): | ||
| current_size = 0 | ||
| if current_size > 0: | ||
| logging.log( |


This pull request enhances the
clone_vm_hdd_imagefunctionality inmfd_kvm/hypervisor.pyby improving error handling, adding more detailed progress tracking forrsync-based image cloning, and updating the unit tests to reflect these changes. The main improvements are stricter source file validation, more informative logging and progress updates during cloning, and more robust test coverage for bothrsyncandscpscenarios.Key changes:
Error Handling and Validation
FileNotFoundErrorimmediately if the source image file does not exist, instead of checking later or after a timeout. [1] [2]Cloning Process Improvements
rsync, the command now includes-av --info=progress2 --outbuf=Nfor verbose output and real-time progress, and logs are captured for progress parsing.rsyncis used, the code reads the log file to parse and log detailed progress, including percentage completed, and handles possible errors in reading the log.Test Enhancements
rsynccommand parameters and the use of thelog_fileargument. [1] [2] [3] [4]scpandrsynccloning, including parsing ofrsyncoutput and checking for accurate log messages.Code Quality and Robustness
rsynclog fails.