-
Notifications
You must be signed in to change notification settings - Fork 32
Pulp import export support #455
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| variables: | ||
| pulp_import_paths: | ||
| help: Extra file path that Pulp can use for content imports. Argument may be used more than once. | ||
| action: append_unique | ||
| type: AbsolutePath | ||
| parameter: --content-import-path | ||
| pulp_export_paths: | ||
| help: Extra file path that Pulp can use for content exports. Argument may be used more than once. | ||
| action: append_unique | ||
| type: AbsolutePath | ||
| parameter: --content-export-path |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,3 +32,4 @@ variables: | |
|
|
||
| include: | ||
| - _flavor_features | ||
| - _pulp | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| variables: | ||
| pulp_import_paths: | ||
| help: Extra file path that Pulp can use for content imports. Argument may be used more than once. | ||
| action: append_unique | ||
| type: AbsolutePath | ||
| parameter: --content-import-path | ||
| pulp_export_paths: | ||
| help: Extra file path that Pulp can use for content exports. Argument may be used more than once. | ||
| action: append_unique | ||
| type: AbsolutePath | ||
| parameter: --content-export-path |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| Pulp Role | ||
| ========= | ||
|
|
||
| Deploys and manages [Pulp](https://pulpproject.org/) as Podman quadlets. | ||
|
|
||
| Variables | ||
| --------- | ||
| - `pulp_container_image`: Container image to use for Pulp (default: `quay.io/foreman/pulp`) | ||
| - `pulp_container_tag`: Container image tag (default: `"3.73"`) | ||
| - `pulp_registry_auth_file`: Path to the registry authentication file (default: `/etc/foreman/registry-auth.json`) | ||
| - `pulp_worker_count`: Number of Pulp workers (default: min of 8 or CPU count) | ||
| - `pulp_content_origin`: URL for the Pulp content service (default: `http://{{ fqdn }}:24816`) | ||
| - `pulp_pulp_url`: URL for the Pulp API service (default: `http://{{ fqdn }}:24817`) | ||
| - `pulp_volumes`: Volume mounts for Pulp containers (default: `/var/lib/pulp:/var/lib/pulp`) | ||
| - `pulp_enable_analytics`: Enable Pulp analytics (default: `false`) | ||
| - `pulp_import_paths`: Paths Pulp can use for content imports (default: `[/var/lib/pulp/sync_imports, /var/lib/pulp/imports]`) | ||
| - `pulp_export_paths`: Paths Pulp can use for content exports (default: `[/var/lib/pulp/exports]`) | ||
| - `pulp_plugins`: Additional Pulp plugins to enable (default: `[pulp_container, pulp_rpm]`) | ||
| - `pulp_database_name`: Name of the Pulp database (default: `pulp`) | ||
| - `pulp_database_user`: Database user (default: `pulp`) | ||
| - `pulp_database_host`: Database host (default: `localhost`) | ||
| - `pulp_database_port`: Database port (default: `5432`) | ||
| - `pulp_database_password`: Database password (required, no default) | ||
| - `pulp_database_ssl_mode`: Database SSL mode (default: `disabled`) | ||
| - `pulp_database_ssl_ca`: Path to the database SSL CA certificate on the control node (default: empty) | ||
|
|
||
| Usage Inside foremanctl | ||
|
ehelms marked this conversation as resolved.
|
||
| ----------------------- | ||
| When used as part of `foremanctl`, the variables are setup as the following | ||
| - `pulp_worker_count`: `--pulp-worker-count` | ||
| - `pulp_import_paths`: `--content-import-path` (may be specified multiple times) | ||
| - `pulp_export_paths`: `--content-export-path` (may be specified multiple times) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,8 +10,12 @@ pulp_worker_count: "{{ [8, ansible_facts['processor_nproc']] | min }}" | |
| pulp_content_service_worker_count: "{{ (2 * ([8, ansible_facts['processor_nproc']] | min)) + 1 }}" | ||
| pulp_api_service_worker_count: "{{ ([4, ansible_facts['processor_nproc']] | min) + 1 }}" | ||
|
|
||
| pulp_volumes: | ||
| - /var/lib/pulp:/var/lib/pulp | ||
| pulp_volumes: >- | ||
| {{ | ||
| ['/var/lib/pulp:/var/lib/pulp'] + | ||
| (pulp_import_paths | map('regex_replace', '^(.+)$', '\1:\1') | list) + | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As an alternative, you could write: I am not sure it's actually nicer than the regex, but wanted to still mention it :) |
||
| (pulp_export_paths | map('regex_replace', '^(.+)$', '\1:\1') | list) | ||
| }} | ||
|
|
||
| pulp_api_container_name: pulp-api | ||
| pulp_content_container_name: pulp-content | ||
|
|
@@ -22,6 +26,11 @@ pulp_pulp_url: "http://{{ ansible_facts['fqdn'] }}:24817" | |
|
|
||
| pulp_enable_analytics: false | ||
|
|
||
| pulp_default_import_paths: ["/var/lib/pulp/sync_imports", "/var/lib/pulp/imports"] | ||
| pulp_default_export_paths: ["/var/lib/pulp/exports"] | ||
| pulp_import_paths: [] | ||
| pulp_export_paths: [] | ||
|
|
||
| pulp_default_plugins: | ||
| - pulp_certguard | ||
| - pulp_file | ||
|
|
@@ -66,6 +75,10 @@ pulp_settings_other_env: | |
| PULP_CONTENT_WORKERS: "{{ pulp_content_service_worker_count }}" | ||
| PULP_TOKEN_AUTH_DISABLED: "true" | ||
| PULP_FLATPAK_INDEX: "true" | ||
| PULP_ALLOWED_IMPORT_PATHS: >- | ||
| {{ pulp_default_import_paths + pulp_import_paths }} | ||
| PULP_ALLOWED_EXPORT_PATHS: >- | ||
| {{ pulp_default_export_paths + pulp_export_paths }} | ||
| PULP_ALLOWED_CONTENT_CHECKSUMS: >- | ||
| ['sha1', 'sha224', 'sha256', 'sha384', 'sha512'] | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,28 @@ | ||
| import json | ||
| import os | ||
|
|
||
| import pytest | ||
| import yaml | ||
|
|
||
| PULP_HOST = 'localhost' | ||
| PULP_API_PORT = 24817 | ||
| PULP_CONTENT_PORT = 24816 | ||
|
|
||
|
|
||
| def load_pulp_paths_from_parameters(): | ||
| test_dir = os.path.dirname(os.path.abspath(__file__)) | ||
| foremanctl_dir = os.path.dirname(test_dir) | ||
| params_file = os.path.join(foremanctl_dir, '.var', 'lib', 'foremanctl', 'parameters.yaml') | ||
|
|
||
| if os.path.exists(params_file): | ||
| with open(params_file, 'r') as f: | ||
| params = yaml.safe_load(f) | ||
| import_paths = params.get('pulp_import_paths', []) | ||
| export_paths = params.get('pulp_export_paths', []) | ||
|
|
||
| return import_paths, export_paths | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def pulp_status_curl(server): | ||
| return server.run(f"curl -k -s -w '%{{stderr}}%{{http_code}}' http://{PULP_HOST}:{PULP_API_PORT}/pulp/api/v3/status/") | ||
|
|
@@ -17,6 +33,11 @@ def pulp_status(pulp_status_curl): | |
| return json.loads(pulp_status_curl.stdout) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def pulp_import_export_paths(): | ||
| return load_pulp_paths_from_parameters() | ||
|
|
||
|
|
||
| def test_pulp_api_service(server): | ||
| pulp_api = server.service("pulp-api") | ||
| assert pulp_api.is_running | ||
|
|
@@ -85,3 +106,40 @@ def test_pulp_worker_target(server): | |
| def test_pulp_manager_check(server): | ||
| result = server.run("podman exec -ti pulp-api pulpcore-manager check --deploy") | ||
| assert result.succeeded | ||
|
|
||
|
|
||
| def test_pulp_import_export_settings(server, pulp_import_export_paths): | ||
| expected_import_paths, expected_export_paths = pulp_import_export_paths | ||
| py = 'from django.conf import settings; import json; print(json.dumps({"import": list(settings.ALLOWED_IMPORT_PATHS), "export": list(settings.ALLOWED_EXPORT_PATHS)}))' | ||
| result = server.run(f"podman exec pulp-api pulpcore-manager shell -c '{py}'") | ||
| assert result.succeeded | ||
| data = json.loads(result.stdout) | ||
| for path in expected_import_paths: | ||
| assert path in data['import'], f"expected {path} in Pulp ALLOWED_IMPORT_PATHS" | ||
| for path in expected_export_paths: | ||
| assert path in data['export'], f"expected {path} in Pulp ALLOWED_EXPORT_PATHS" | ||
|
|
||
|
|
||
| def test_pulp_import_directories(server, pulp_import_export_paths): | ||
| import_paths, _ = pulp_import_export_paths | ||
| for path in import_paths: | ||
| assert server.file(path).is_directory | ||
|
|
||
|
|
||
| def test_pulp_export_directories(server, pulp_import_export_paths): | ||
| _, export_paths = pulp_import_export_paths | ||
| for path in export_paths: | ||
| 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): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My point is that this isn't testing the user input anywhere and therefore not checking whether the custom parts are working. Consider adding these to CI to be able to assert that they work.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I fixed this in my latest commit going to watch the CI run |
||
| import_paths, export_paths = pulp_import_export_paths | ||
| result = server.run(f"podman inspect {container} --format '{{{{json .Mounts}}}}'") | ||
| assert result.succeeded | ||
| mounts = json.loads(result.stdout) | ||
| destinations = [mount['Destination'] for mount in mounts] | ||
|
|
||
| for path in import_paths + export_paths: | ||
| mounted = path in destinations or any(path.startswith(d + '/') for d in destinations) | ||
| assert mounted, f"expected {path} to be mounted as a volume in {container}" | ||
Uh oh!
There was an error while loading. Please reload this page.