Skip to content

Pulp import export support#455

Open
aidenfine wants to merge 13 commits intotheforeman:masterfrom
aidenfine:SAT-44059-pulp-import-export-support
Open

Pulp import export support#455
aidenfine wants to merge 13 commits intotheforeman:masterfrom
aidenfine:SAT-44059-pulp-import-export-support

Conversation

@aidenfine
Copy link
Copy Markdown

@aidenfine aidenfine commented Apr 17, 2026

Why are you introducing these changes? (Problem description, related links)

Jira

Add pulp content import/export arguments.

What are the changes introduced in this pull request?

You can pass in multiple args of either --content-import-path or --content-export-path as many times as you want, since these will be appended as a list. These folders will be automatically created.

How to test this pull request

pytest tests/pulp_test.py

Can also manually test these steps.

# create env
./foremanctl deploy --foreman-initial-admin-password=changeme --tuning development --content-import-path /mycontentpath/import --content-export-path /mycontentpath/export --content-export-path /mycontentpath/export2

# ssh 
vagrant ssh quadlet

# verify imports (should see a list with exported/imported paths)
sudo podman exec pulp-api pulpcore-manager shell -c "from django.conf import settings; print(settings.ALLOWED_IMPORT_PATHS)"

# exports
sudo podman exec pulp-api pulpcore-manager shell -c "from django.conf import settings; print(settings.ALLOWED_EXPORT_PATHS)"

@aidenfine aidenfine changed the title Sat-44059 pulp import export support Pulp import export support Apr 17, 2026
Comment thread src/playbooks/deploy/metadata.obsah.yaml Outdated
Comment thread src/roles/pulp/README.md
Comment thread src/roles/pulp/README.md
Comment thread src/roles/pulp/README.md Outdated
Comment thread src/roles/pulp/tasks/main.yaml Outdated
Comment thread src/roles/pulp/defaults/main.yaml Outdated
PULP_ALLOWED_IMPORT_PATHS: >-
{{ pulp_default_import_path + pulp_extra_import_paths }}
PULP_ALLOWED_EXPORT_PATHS: >-
{{ pulp_default_export_path + pulp_extra_export_paths }}
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.

Locally I have this:
PULP_ALLOWED_IMPORT_PATHS: >-
['/var/lib/pulp/sync_imports', '/var/lib/pulp/imports']
PULP_ALLOWED_EXPORT_PATHS: >-
['/var/lib/pulp/exports']

These would be the default paths..

Comment thread src/roles/pulp/defaults/main.yaml Outdated
@ianballou
Copy link
Copy Markdown

ianballou commented Apr 17, 2026

Can we make these import/export arguments also available via forge deploy-dev ?

@ehelms
Copy link
Copy Markdown
Member

ehelms commented Apr 17, 2026

Can we make these import/export arguments also available via forge deploy-dev ?

Consider this method for defining them -- https://github.com/theforeman/foremanctl/blob/master/docs/developer/playbooks-and-roles.md#shared-metadata-fragments

@ianballou
Copy link
Copy Markdown

ianballou commented Apr 17, 2026

I just tried this out, seeing the following in my pulp-api service definition:

Environment='PULP_ALLOWED_IMPORT_PATHS=['"'"'/var/lib/pulp/imports'"'"', '"'"'/var/lib/pulp/my_imports'"'"', '"'"'/var/lib/pulp/my_exports'"'"', '"'"'/var/lib/pulp/exports'"'"']'
Environment='PULP_ALLOWED_EXPORT_PATHS=['"'"'/var/lib/pulp/exports'"'"', '"'"'/var/lib/pulp/my_exports'"'"']'

So far so good, assuming the escaping is correct. And yes, I like to be able to import from my export directory.

@ianballou
Copy link
Copy Markdown

Export and import worked! I was able to generate /var/lib/pulp/exports/Default_Organization/Export-Zoo-1/1.0/2026-04-17T17-37-04-00-00/ and import it back into another repository. Perfect.

@aidenfine
Copy link
Copy Markdown
Author

@ehelms I am not too sure on how to make sure the created import and export directories are mounted into the container. Can you point me into the right direction. Maybe somewhere in the code we handle a similar workflow

@ehelms
Copy link
Copy Markdown
Member

ehelms commented Apr 17, 2026

@ehelms I am not too sure on how to make sure the created import and export directories are mounted into the container. Can you point me into the right direction. Maybe somewhere in the code we handle a similar workflow

You'll need to do something like this -- https://github.com/theforeman/foremanctl/blob/master/src/roles/pulp/tasks/main.yaml#L137

Comment thread src/roles/pulp/defaults/main.yaml Outdated
@aidenfine aidenfine requested review from ehelms and evgeni April 24, 2026 18:03
Comment thread src/roles/pulp/defaults/main.yaml Outdated
Comment thread src/roles/pulp/defaults/main.yaml Outdated
pulp_volumes: >-
{{
['/var/lib/pulp:/var/lib/pulp'] +
(pulp_import_paths | map('regex_replace', '^(.+)$', '\1:\1') | list) +
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.

What are these regexs doing?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

lets take one item from pulp_import_paths and call it string1, so string1="/foo/bar"
this regex turns string1 into the same format as the line above. ('/var/lib/pulp:/var/lib/pulp').

So after string1 runs through regex, we get "/foo/bar:/foo:bar"

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.

As /var/lib/pulp is already mounted as a volume, do we want / need to mount the default paths? I realize this can make the logic a bit more complicated but I worry about performance of mounting unnecessary volumes, especially those that are sub-directories of an existing mount.

foreman_development_github_username:
help: GitHub username to add as additional remote for git checkouts
action: store
pulp_import_paths:
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.

You could define these in a file like https://github.com/theforeman/foremanctl/blob/master/src/playbooks/_database_connection/metadata.obsah.yaml and then include that file in both deploy and deploy-dev.

Comment thread src/roles/pulp/defaults/main.yaml Outdated
pulp_volumes: >-
{{
['/var/lib/pulp:/var/lib/pulp'] +
((pulp_default_import_paths + pulp_import_paths) | map('regex_replace', '^(.+)$', '\1:\1') | list) +
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.

Suggested change
((pulp_default_import_paths + pulp_import_paths) | map('regex_replace', '^(.+)$', '\1:\1') | list) +
((pulp_import_paths) | map('regex_replace', '^(.+)$', '\1:\1') | list) +

I think this would be the way to prevent known double-mounting? Same for line below.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Okay I will make this change today

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Okay pushed that change with some test changes as well

Comment thread tests/pulp_test.py
assert server.file(path).is_directory

@pytest.mark.parametrize("container", ["pulp-api", "pulp-content", "pulp-worker-1"])
def test_pulp_import_export_volume_mounts(server, container, pulp_import_export_paths):
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.

My read on this is that it will check only the defaults right now, since neither the tests or the test setup is specifying any additional paths. Have you thought about that and adding specification of additional paths to the test setup?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It will also read custom paths as well the fixture will pull items from the environment and verify that any path in the PULP_ALLOWED_IMPORT_PATHS or PULP_ALLOWED_EXPORT_PATHS is present AND a volume mount.

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

Successfully merging this pull request may close these issues.

5 participants