Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ebs__download_snapshots fails when computing out_dir.relative_to('.') #444

Open
niooss-ledger opened this issue Jul 8, 2024 · 0 comments

Comments

@niooss-ledger
Copy link

Hello,
I tried downloading an EBS snapshot using Pacu 1.6.0 and got an error after all the data was downloaded:

Pacu (mysession:xxx) > run ebs__download_snapshots --region eu-west-1 --snapshot-id snap-01[[REDACTED]]
  Running module ebs__download_snapshots...
Output Path: /root/.local/share/pacu/mysession/downloads/ebs/snapshots/snap-01[[REDACTED]].img
Truncating file to 8.0 GB
Saved block 16369 of 16369
[2024-07-08 09:40:57] Pacu encountered an error while running the previous command. Check /root/.local/share/pacu/mysession/error_log.txt for technical details. [LOG LEVEL: MINIMAL]

    <class 'ValueError'>: '/root/.local/share/pacu/mysession/downloads/ebs/snapshots' is not in the subpath of '' OR one path is relative and the other is absolute.

The error log file (/root/.local/share/pacu/mysession/error_log.txt) contains this call trace:

[2024-07-08 09:40:57] (mysession): 
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/pacu/main.py", line 1827, in run_gui
    self.idle()
  File "/usr/local/lib/python3.11/dist-packages/pacu/main.py", line 1681, in idle
    self.parse_command(command)
  File "/usr/local/lib/python3.11/dist-packages/pacu/main.py", line 600, in parse_command
    self.parse_exec_module_command(command)
  File "/usr/local/lib/python3.11/dist-packages/pacu/main.py", line 786, in parse_exec_module_command
    self.exec_module(command)
  File "/usr/local/lib/python3.11/dist-packages/pacu/main.py", line 1003, in exec_module
    summary_data = module.main(command[2:], self)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pacu/modules/ebs__download_snapshots/main.py", line 94, in main
    out_dir=str(out_dir.relative_to('.')),
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/pathlib.py", line 731, in relative_to
    raise ValueError("{!r} is not in the subpath of {!r}"
<class 'ValueError'>: '/root/.local/share/pacu/mysession/downloads/ebs/snapshots' is not in the subpath of '' OR one path is relative and the other is absolute.

The issue is that out_dir is not relative to the current directory, in

return SummaryData(
out_dir=str(out_dir.relative_to('.')),
snapshot_id=snapshot_id,
snapshot_path=str(snap.path),
vagrantfile=str(utils.init_vagrant(out_dir, True)),
)

(In my use-case, out_dir was "/root/.local/share/pacu/mysession/downloads/ebs/snapshots/").

The call to .relative_to('.') was added in commit e5c3f36 ("ebs__download_snapshots fixes and improvements") from PR #232 and it seems that at the time, the download directory was ./sessions/$SESSION/downloads/ebs/ instead of ~/.local/share/pacu/.... I believe this call to .relative_to('.') should now be removed. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant