Skip to content

Conversation

@Riushda
Copy link
Contributor

@Riushda Riushda commented Oct 1, 2025

Podman 5.6.0 introduces 2 new commands: podman volume import and export. I was willing to add support for these 2 commands in the python sdk because they are very useful in some specific volumes backup scenario I have in mind.

Closes #574

@Riushda Riushda force-pushed the issue/add_export_and_import_commands branch from 77b7b17 to 6755b86 Compare October 1, 2025 21:01
Copy link
Contributor

@inknos inknos left a comment

Choose a reason for hiding this comment

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

Overall looks good, only two points to address.

Minor fix, based on my preference: would you consider squashing the commits together? I believe a single commit would fit nicely in the log for this change.

thanks!

@Riushda Riushda force-pushed the issue/add_export_and_import_commands branch 3 times, most recently from 4642c37 to e8e42e7 Compare October 2, 2025 20:22
@Riushda Riushda requested a review from inknos October 2, 2025 20:28
@Riushda Riushda force-pushed the issue/add_export_and_import_commands branch from e8e42e7 to 7f3b50a Compare October 2, 2025 21:31
@inknos
Copy link
Contributor

inknos commented Oct 2, 2025

code looks good now! let me be pedantic, but could you add a test for path and data too? you can mock the API call in the unit tests, check podman/tests/unit/test_volumesmanager.py

Signed-off-by: Riushda <mohandesdariush@gmail.com>

fix export and import functions

Signed-off-by: Riushda <mohandesdariush@gmail.com>

[docs] Update testing section

Add common issues section
Add docs on how to skip tests based on podman's version and os

Signed-off-by: Nicola Sella <nsella@redhat.com>
Signed-off-by: Riushda <mohandesdariush@gmail.com>

format

Signed-off-by: Riushda <mohandesdariush@gmail.com>

Add import and export test

Signed-off-by: Riushda <mohandesdariush@gmail.com>

Do not test if podman version is older than 5.6.0

Signed-off-by: Riushda <mohandesdariush@gmail.com>

Fix docstring

Signed-off-by: Riushda <mohandesdariush@gmail.com>

Fix export archive command

Signed-off-by: Riushda <mohandesdariush@gmail.com>

Add path to import function

Signed-off-by: Riushda <mohandesdariush@gmail.com>

Add default values

Signed-off-by: Riushda <mohandesdariush@gmail.com>

Fix typing

Signed-off-by: Riushda <mohandesdariush@gmail.com>

Add mock tests

Signed-off-by: Riushda <mohandesdariush@gmail.com>
@Riushda Riushda force-pushed the issue/add_export_and_import_commands branch from 7f3b50a to 382d30a Compare October 3, 2025 18:00
content=b'exported_archive',
)
actual = self.client.volumes.export_archive("dbase")
self.assertIsInstance(actual, bytes)
Copy link
Contributor Author

@Riushda Riushda Oct 3, 2025

Choose a reason for hiding this comment

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

To be honest, I'm not sure about the value of these mock tests (for the import and export). I wouldn't have added them if you didn't ask for it.

Copy link
Contributor

Choose a reason for hiding this comment

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

My motivation is primarily code coverage. In addition to this, tests help me a lot with future features working with the community, even when they are simple.

I'd like to hear your opinion: why you are not sure of the value for these specific tests. Do you mean they are too trivial?

thanks a lot for the patience and for updating the pr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was mainly talking about the functions I added. There isn't much to test without an actual volume and archive file. But don't get me wrong, I think mock tests in general are great to add more test coverage in particular for complex scenario that are not easy to reproduce in actual integration test.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be very nice to do something like this in python, but we are missing other options in the python bindings to do so

podman volume create testvol
podman volume export testvol --output testvol.tar
mkdir testvol
tar -xvf testvol.tar -C testvol/
touch  testvol/test
tar -rf testvol.tar testvol/test
cat testvol.tar | podman volume import testvol -
podman unshare
podman volume mount testvol
ls /home/nsella/.local/share/containers/storage/volumes/testvol/_data/testvol/test

So I think your tests are now good

@inknos
Copy link
Contributor

inknos commented Oct 6, 2025

/approve
/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 6, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inknos, Riushda

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Oct 6, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 599b17a into containers:main Oct 6, 2025
22 checks passed
@Riushda
Copy link
Contributor Author

Riushda commented Oct 6, 2025

Thanks for the review !

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.

Add support for podman volume import and export

2 participants