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

Add rpm_package module #105

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ziegenberg
Copy link
Contributor

Based on PR #34 on the work by Jacob Floyd (@cognifloyd).

Rebased and solved the merge conflicts. Also made small changes to the test (e.g., using FQCN)

@ziegenberg
Copy link
Contributor Author

Mhm, tests fail.

Recording the fixtures fails for pulp.squeezer.rpm_package with the following error message:

The full traceback is:
Traceback (most recent call last):

  File "/tmp/ansible_pulp.squeezer.rpm_package_payload_s13x11zx/ansible_pulp.squeezer.rpm_package_payload.zip/ansible_collections/pulp/squeezer/plugins/modules/rpm_package.py", line 99, in main

  File "/tmp/ansible_pulp.squeezer.rpm_package_payload_s13x11zx/ansible_pulp.squeezer.rpm_package_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/pulp.py", line 315, in process
    self.create()

  File "/tmp/ansible_pulp.squeezer.rpm_package_payload_s13x11zx/ansible_pulp.squeezer.rpm_package_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/pulp.py", line 601, in create
    super(PulpFileContent, self).create()

  File "/tmp/ansible_pulp.squeezer.rpm_package_payload_s13x11zx/ansible_pulp.squeezer.rpm_package_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/pulp.py", line 233, in create
    task = PulpTask(self.module, {"pulp_href": response["task"]}).wait_for()

  File "/tmp/ansible_pulp.squeezer.rpm_package_payload_s13x11zx/ansible_pulp.squeezer.rpm_package_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/pulp.py", line 484, in wait_for
    raise Exception(

Exception: Task failed to complete. (failed; RPM file cannot be parsed for metadata)
fatal: [tests]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "digest": "467c73425dcc43ef64dccf50d70fdcdb7e3bba5706c37b534a0f4f043aa7b688",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "pulp_url": "http://localhost:8080",
            "refresh_api_cache": false,
            "relative_path": "data/fox-1.1-2.noarch.rpm",
            "sha256": "467c73425dcc43ef64dccf50d70fdcdb7e3bba5706c37b534a0f4f043aa7b688",
            "state": "present",
            "username": "admin",
            "validate_certs": true
        }
    },
    "msg": "Task failed to complete. (failed; RPM file cannot be parsed for metadata)"
}

@ziegenberg
Copy link
Contributor Author

Doing a live test gets me this error:

pulp [c9ed3d03baa34790a3e26095a4f63e65]: 127.0.0.1 - admin [13/Jul/2022:17:42:48 +0000] "GET /pulp/api/v3/artifacts/?limit=1&sha256=467c73425dcc43ef64dccf50d70fdcdb7e3bba5706c37b534a0f4f043aa7b688 HTTP/1.0" 200 52 "-" "Python-urllib/3.8"
pulp [2d052d45f05742299edd4a1d1d39894c]: 127.0.0.1 - admin [13/Jul/2022:17:42:48 +0000] "POST /pulp/api/v3/artifacts/ HTTP/1.0" 201 632 "-" "Python-urllib/3.8"
pulp [036bd7889bbc43109ab82ddace9cd870]: 127.0.0.1 - admin [13/Jul/2022:17:42:48 +0000] "GET /pulp/api/v3/content/rpm/packages/?limit=1&sha256=467c73425dcc43ef64dccf50d70fdcdb7e3bba5706c37b534a0f4f043aa7b688 HTTP/1.0" 200 52 "-" "Python-urllib/3.8"
pulp [9a3427b98d5d4570b203edbc12fbe0e3]: 127.0.0.1 - admin [13/Jul/2022:17:42:48 +0000] "GET /pulp/api/v3/artifacts/?limit=1&sha256=467c73425dcc43ef64dccf50d70fdcdb7e3bba5706c37b534a0f4f043aa7b688 HTTP/1.0" 200 684 "-" "Python-urllib/3.8"
pulp [bf6c68e0a7a7493cb87fb751d99c51c7]: 127.0.0.1 - admin [13/Jul/2022:17:42:48 +0000] "POST /pulp/api/v3/content/rpm/packages/ HTTP/1.0" 202 67 "-" "Python-urllib/3.8"
pulp [bf6c68e0a7a7493cb87fb751d99c51c7]: pulpcore.tasking.pulpcore_worker:INFO: Starting task 34ad2d11-b171-4576-acb5-786c5374d940
pulp [32c0f299b752463bb6eefb2d3caff860]: 127.0.0.1 - admin [13/Jul/2022:17:42:49 +0000] "GET /pulp/api/v3/tasks/34ad2d11-b171-4576-acb5-786c5374d940/ HTTP/1.0" 200 507 "-" "Python-urllib/3.8"
pulp [bf6c68e0a7a7493cb87fb751d99c51c7]: pulp_rpm.app.serializers.package:INFO: Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pulp_rpm/app/serializers/package.py", line 244, in deferred_validate
    new_pkg = _prepare_package(data["artifact"], data["relative_path"])
  File "/usr/local/lib/python3.8/site-packages/pulp_rpm/app/shared_utils.py", line 27, in _prepare_package
    with tempfile.NamedTemporaryFile("wb", dir=".", suffix=filename) as temp_file:
  File "/usr/lib64/python3.8/tempfile.py", line 540, in NamedTemporaryFile
    (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
  File "/usr/lib64/python3.8/tempfile.py", line 250, in _mkstemp_inner
    fd = _os.open(file, flags, 0o600)
FileNotFoundError: [Errno 2] No such file or directory: './tmp50s37ogwdata/fox-1.1-2.noarch.rpm'

pulp [bf6c68e0a7a7493cb87fb751d99c51c7]: pulpcore.tasking.pulpcore_worker:INFO: Task 34ad2d11-b171-4576-acb5-786c5374d940 failed (RPM file cannot be parsed for metadata)
pulp [bf6c68e0a7a7493cb87fb751d99c51c7]: pulpcore.tasking.pulpcore_worker:INFO:   File "/usr/local/lib/python3.8/site-packages/pulpcore/tasking/pulpcore_worker.py", line 445, in _perform_task
    result = func(*args, **kwargs)

  File "/usr/local/lib/python3.8/site-packages/pulpcore/app/tasks/base.py", line 37, in general_create
    serializer.is_valid(raise_exception=True)

  File "/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py", line 227, in is_valid
    self._validated_data = self.run_validation(self.initial_data)

  File "/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py", line 429, in run_validation
    value = self.validate(value)

  File "/usr/local/lib/python3.8/site-packages/pulpcore/plugin/serializers/content.py", line 104, in validate
    data = self.deferred_validate(data)

  File "/usr/local/lib/python3.8/site-packages/pulp_rpm/app/serializers/package.py", line 247, in deferred_validate
    raise NotAcceptable(detail="RPM file cannot be parsed for metadata")

@ziegenberg
Copy link
Contributor Author

ziegenberg commented Jul 13, 2022

Tests currently fail due to pulp/pulp_rpm#2403.

Based on PR pulp#34 on the work by Jacob Floyd (@cognifloyd).

Co-authored-by: Jacob Floyd <[email protected]>
Signed-off-by: Daniel Ziegenberg <[email protected]>
@ziegenberg
Copy link
Contributor Author

ziegenberg commented Aug 1, 2022

Waiting on image rebuild for ghcr.io/pulp/pulp:latest to contain the recent pulp-rpm 3.17.8 release.

@stejoo
Copy link
Contributor

stejoo commented Sep 7, 2023

Thanks for creating this!
I realize this is quite a bump after a year. I have been looking for this functionality.
I am currently creating an Ansible Playbook to upload an RPM file and add it to a repository. The documentation I found (https://docs.pulpproject.org/pulp_rpm/workflows/upload.html) mentions the pulp rpm content command for which I have been unable to find a matching module. This seems to be just that?

Is there perhaps some energy and time left to complete this work? If so: can I help test it or be useful in some other way?

Or is there a better way of getting this task done, using Ansible?
Thank you for any insights and information in advance.

@ziegenberg
Copy link
Contributor Author

Hi @stejoo!

Sorry for the late reply. If I find time in the coming weeks, I might be able to complete this PR. But I can't promise you anything.

@stejoo
Copy link
Contributor

stejoo commented Oct 5, 2023

Thanks for your reply @ziegenberg !

Time is often a problem, I know that very well. I remain curious and looking out for this functionality in the Pulp Squeezer set of Ansible modules. So I look forward to your solution in the possible future.

In the mean time I have been able to get the job done by performing API calls. Mainly by replicating the instructions shown in the documentation with regards to the "content" steps. I put that work in a Gist so that others who need the functionality as well may (temporary?) benefit: https://gist.github.com/stejoo/134de3fbb69f778590e26d2a9523db0f

@mnasiadka
Copy link

Hello, I would be interested in finishing this work - @ziegenberg is that ok if I would reuse your work in a new PR and give you credits for that?

@ziegenberg
Copy link
Contributor Author

Sure, go ahead! I just don't have enough spare time to get it over the finish line.

Put a Co-authored-by git trailer in the commit message body, if you squash everything, and I'm fine with that.

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.

3 participants