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

Initial version to make it run on Podman #69

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

Thulium-Drake
Copy link
Contributor

Still a work in progress, but it should migrate existing PyPI installation to podman while keeping the data :-)

@softwarefactory-project-zuul
Copy link

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/daf1892c5fa246a1902aa7310734fb5c

✔️ ara-role-api-distributed-sqlite SUCCESS in 14m 13s
✔️ ara-role-api-mysql SUCCESS in 14m 26s
✔️ ara-role-api-postgresql SUCCESS in 15m 46s
✔️ ara-role-api-gunicorn-nginx SUCCESS in 11m 41s
✔️ ara-role-api-gunicorn-nginx-client-cert SUCCESS in 12m 11s
ara-role-api-fedora-packages FAILURE in 5m 12s (non-voting)

@softwarefactory-project-zuul
Copy link

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/e9cf5d1476494169b3db0cafc8ef6333

✔️ ara-role-api-distributed-sqlite SUCCESS in 19m 46s
✔️ ara-role-api-mysql SUCCESS in 14m 53s
✔️ ara-role-api-postgresql SUCCESS in 14m 15s
✔️ ara-role-api-gunicorn-nginx SUCCESS in 21m 44s
✔️ ara-role-api-gunicorn-nginx-client-cert SUCCESS in 11m 45s
ara-role-api-fedora-packages FAILURE in 9m 37s (non-voting)

@Thulium-Drake Thulium-Drake mentioned this pull request Jul 17, 2023
@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/ff0b0a31d0dd4382b49bbff728e2c445

✔️ ara-role-api-distributed-sqlite SUCCESS in 14m 34s
✔️ ara-role-api-mysql SUCCESS in 18m 36s
✔️ ara-role-api-postgresql SUCCESS in 17m 23s
✔️ ara-role-api-gunicorn-nginx SUCCESS in 12m 47s
✔️ ara-role-api-gunicorn-nginx-client-cert SUCCESS in 16m 16s
ara-role-api-podman ERROR Unable to find playbook /var/lib/zuul/builds/5bbc70ce3d624c28b1281e62cca854c7/untrusted/project_0/github.com/ansible-community/ara-collection/tests/with_podman.yaml in 3s
ara-role-api-fedora-packages FAILURE in 6m 10s (non-voting)

@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/1aa6eed4a9274266830acf394c4fd000

✔️ ara-role-api-distributed-sqlite SUCCESS in 14m 38s
✔️ ara-role-api-mysql SUCCESS in 22m 49s
✔️ ara-role-api-postgresql SUCCESS in 23m 40s
✔️ ara-role-api-gunicorn-nginx SUCCESS in 18m 20s
✔️ ara-role-api-gunicorn-nginx-client-cert SUCCESS in 18m 13s
ara-role-api-podman FAILURE in 5m 14s
ara-role-api-fedora-packages FAILURE in 5m 16s (non-voting)

description: |
Desploys the ARA API server on Fedora 36 as well as CentOS Stream 8/9
in a Podman container and tests it using the default sqlite database backend.
run: tests/with_podman.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool! We should bump that to Fedora 38 like I did recently for ara but I can take care of that in another 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.

Let's split that, first let's make this work ^^

Copy link
Contributor

Choose a reason for hiding this comment

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

I like that there is already a job for testing podman and that it is even passing, nice work :)

Comment on lines 1 to 22
---
- name: Detecting existing PyPI installation
ansible.builtin.stat:
path: "{{ ara_api_venv_path }}"
register: existing_pypi_install

- name: Remove PyPI virtualenv
ansible.builtin.file:
path: "{{ ara_api_venv_path }}"
state: absent
when: existing_pypi_install['stat']['exists']

- name: Detecting existing sqlite database
ansible.builtin.stat:
path: "{{ ara_api_database_name }}"
register: existing_sqlite_database

- name: Move sqlite database to new location
ansible.builtin.command: mv {{ ara_api_database_name }} {{ ara_api_root_dir }}/ansible.sqlite
when:
- existing_sqlite_database['stat']['exists']
- ara_api_database_engine == 'django.db.backends.sqlite3'
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 I understand the intent here but I'm not sure whether we should do this automatically.

The collection doesn't (yet) do anything special when switching between installation types or database backends so it feels a bit out of place to go out and delete venvs and move files around.

If the concern is that there might already be an existing installation, maybe we could print a helpful debug message about it and fail the playbook such that the user is given the opportunity to clean it up or automate it outside the collection.

We can always reconsider if it turns out to be a big issue or something we really want to support.

Copy link
Contributor Author

@Thulium-Drake Thulium-Drake Jul 22, 2023

Choose a reason for hiding this comment

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

I put it behind a flag for now :-) and I added notice in the script to notify the user.

The reason I put it there is that it's little extra effort to clean up the PyPI installation (which in my case broke because I upgraded to Debian 12 which doesn't take kindly to pip install any longer)

- name: Ensure ARA API container
containers.podman.podman_container:
name: ara-api
image: recordsansible/ara-api:{{ ara_api_version }}
Copy link
Contributor

Choose a reason for hiding this comment

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

ara_api_version defaults to master, right ? That tag doesn't exist.

I'm not convinced we need an extra variable for the container image tag but it's not the end of the world.
We could also substitute master for latest, perhaps.

What do you think ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I completely missed that, as I have mine configured to use 'latest', I have updated the defaults, because if the tag does not exist, it makes no sense to have it as a default :)

name: ara-api
image: recordsansible/ara-api:{{ ara_api_version }}
state: present
auto_remove: true
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it really be "auto_remove" ? If it deletes itself on exit, then the systemd service wouldn't really have the opportunity to stop or restart it.

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 put it there to make the podman generate systemd command below idempotent with what is created :)

The systemd service knows how to handle it, but it needs an existing container to template from

@dmsimard
Copy link
Contributor

Hello and thanks for the PR @Thulium-Drake ❤️

I have some questions and comments in line but this is good work. I'm looking forward to merge it when it's ready :)

@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/dfac4700396a48be82a66c458c5da59e

✔️ ara-role-api-distributed-sqlite SUCCESS in 13m 15s
✔️ ara-role-api-mysql SUCCESS in 14m 46s
✔️ ara-role-api-postgresql SUCCESS in 15m 39s
✔️ ara-role-api-gunicorn-nginx SUCCESS in 12m 12s
✔️ ara-role-api-gunicorn-nginx-client-cert SUCCESS in 12m 20s
ara-role-api-podman FAILURE in 2m 53s
ara-role-api-fedora-packages FAILURE in 6m 34s (non-voting)

@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/b13a34379f7d42679d8ceb1331d7048b

✔️ ara-role-api-distributed-sqlite SUCCESS in 15m 34s
✔️ ara-role-api-mysql SUCCESS in 14m 52s
✔️ ara-role-api-postgresql SUCCESS in 19m 52s
✔️ ara-role-api-gunicorn-nginx SUCCESS in 13m 59s
✔️ ara-role-api-gunicorn-nginx-client-cert SUCCESS in 12m 22s
ara-role-api-podman FAILURE in 3m 13s
ara-role-api-fedora-packages FAILURE in 6m 02s (non-voting)

@Thulium-Drake
Copy link
Contributor Author

So I ran into 2 issues deploying it on a fresh system (I think I forgot to thoroughly clean my dev system the other days :-) and I didn't test RHEL yet):

  • Generating a secret key uses Django tools, I have replaced that with a generic oneliner that should do the same
  • SELinux context for the Podman pod are not correct. I'll try to figure this one out tomorrow, it's definitely something with filecontext, but I need to do some poking and prodding to get it to work.

@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/014c6d78d2374eadac433b4eeb7f7152

ara-role-api-distributed-sqlite FAILURE in 12m 22s
ara-role-api-mysql FAILURE in 11m 55s
ara-role-api-postgresql FAILURE in 7m 20s
ara-role-api-gunicorn-nginx FAILURE in 9m 56s
ara-role-api-gunicorn-nginx-client-cert FAILURE in 9m 58s
ara-role-api-podman FAILURE in 2m 51s
ara-role-api-fedora-packages FAILURE in 5m 55s (non-voting)

@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/979ee085aaf3439ab1e7197a95efc3f1

ara-role-api-distributed-sqlite FAILURE in 12m 08s
ara-role-api-mysql FAILURE in 11m 15s
ara-role-api-postgresql FAILURE in 7m 16s
ara-role-api-gunicorn-nginx FAILURE in 10m 06s
ara-role-api-gunicorn-nginx-client-cert FAILURE in 9m 11s
ara-role-api-podman FAILURE in 3m 11s
ara-role-api-fedora-packages FAILURE in 6m 59s (non-voting)

@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/f319dcf4f1d7411e8ec07b491a67a00b

ara-role-api-distributed-sqlite FAILURE in 11m 32s
ara-role-api-mysql FAILURE in 10m 23s
ara-role-api-postgresql FAILURE in 7m 02s
ara-role-api-gunicorn-nginx FAILURE in 9m 03s
ara-role-api-gunicorn-nginx-client-cert FAILURE in 9m 53s
ara-role-api-podman FAILURE in 2m 14s
ara-role-api-fedora-packages FAILURE in 4m 28s (non-voting)

@softwarefactory-project-zuul
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/e08565f662eb440a91ed17ebb4b1d38b

ara-role-api-distributed-sqlite FAILURE in 11m 42s
ara-role-api-mysql FAILURE in 12m 03s
ara-role-api-postgresql FAILURE in 7m 33s
ara-role-api-gunicorn-nginx FAILURE in 9m 34s
ara-role-api-gunicorn-nginx-client-cert FAILURE in 10m 17s
ara-role-api-podman FAILURE in 3m 15s
ara-role-api-fedora-packages FAILURE in 5m 10s (non-voting)

@Thulium-Drake
Copy link
Contributor Author

recheck

@Thulium-Drake
Copy link
Contributor Author

@dmsimard I think CI needs some love, all tests seem to fail, even those this PR didn't touch 😅

Do I need to rebase and try again? Or do we need to work on that first (and if so, what needs fixing?)

Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/42b1b463b310428a9f9a1a7e576af122

ara-role-api-distributed-sqlite FAILURE in 11m 37s
ara-role-api-mysql FAILURE in 12m 12s
ara-role-api-postgresql FAILURE in 6m 52s
ara-role-api-gunicorn-nginx FAILURE in 10m 02s
ara-role-api-gunicorn-nginx-client-cert FAILURE in 9m 26s
ara-role-api-podman FAILURE in 3m 14s
ara-role-api-fedora-packages FAILURE in 5m 31s (non-voting)

@dmsimard
Copy link
Contributor

@dmsimard I think CI needs some love, all tests seem to fail, even those this PR didn't touch 😅

Do I need to rebase and try again? Or do we need to work on that first (and if so, what needs fixing?)

I need some time but I will look into it. Sorry about the delay.

Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/9c2accc34258420d9ffa289bcddcd655

ara-role-api-distributed-sqlite FAILURE in 11m 57s
ara-role-api-mysql FAILURE in 10m 45s
ara-role-api-postgresql FAILURE in 6m 12s
ara-role-api-gunicorn-nginx FAILURE in 9m 25s
ara-role-api-gunicorn-nginx-client-cert FAILURE in 9m 33s
ara-role-api-podman FAILURE in 2m 25s
ara-role-api-fedora-packages FAILURE in 6m 13s (non-voting)

@dmsimard
Copy link
Contributor

I am still interested in this. I will circle back to the PR once there is a bugfix release out.

Thanks for your patience.

@Thulium-Drake
Copy link
Contributor Author

@dmsimard Rebased! :-)

@Thulium-Drake
Copy link
Contributor Author

recheck

Copy link

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/50f0bfce157242a1bea96a9c7e8cb6be

✔️ ara-role-api-distributed-sqlite SUCCESS in 5m 45s
✔️ ara-role-api-mysql SUCCESS in 6m 37s
✔️ ara-role-api-postgresql SUCCESS in 6m 18s
✔️ ara-role-api-gunicorn-nginx SUCCESS in 5m 37s
✔️ ara-role-api-gunicorn-nginx-client-cert SUCCESS in 4m 46s
✔️ ara-role-api-podman SUCCESS in 6m 02s
✔️ ara-role-api-fedora-packages SUCCESS in 5m 18s (non-voting)

Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/08b4a0a03d724a28b9145104b844a702

ara-role-api-distributed-sqlite NODE_FAILURE Node request 200-0007632258 failed in 0s
ara-role-api-mysql NODE_FAILURE Node request 200-0007632259 failed in 0s
ara-role-api-postgresql NODE_FAILURE Node request 200-0007632260 failed in 0s
✔️ ara-role-api-gunicorn-nginx SUCCESS in 4m 59s
✔️ ara-role-api-gunicorn-nginx-client-cert SUCCESS in 5m 07s
ara-role-api-podman NODE_FAILURE Node request 200-0007632263 failed in 0s
✔️ ara-role-api-fedora-packages SUCCESS in 5m 06s (non-voting)

@Thulium-Drake
Copy link
Contributor Author

recheck

Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/be15cf02b07842a29a47cbff5f033042

✔️ ara-role-api-distributed-sqlite SUCCESS in 6m 23s
✔️ ara-role-api-mysql SUCCESS in 7m 45s
✔️ ara-role-api-postgresql SUCCESS in 8m 00s
✔️ ara-role-api-gunicorn-nginx SUCCESS in 5m 33s
ara-role-api-gunicorn-nginx-client-cert FAILURE in 6m 09s
ara-role-api-podman FAILURE in 3m 47s
✔️ ara-role-api-fedora-packages SUCCESS in 6m 05s (non-voting)

@Thulium-Drake
Copy link
Contributor Author

So there seems to be an issue with the podman test, it uses an older release of the containers.podman collection which does not support the pull parameter.

However, I think that parameter is really important to have, as leaving it default might cause end users to run with outdated images..

Is there any way to set that requirement? :-)

@dmsimard
Copy link
Contributor

So there seems to be an issue with the podman test, it uses an older release of the containers.podman collection which does not support the pull parameter.

However, I think that parameter is really important to have, as leaving it default might cause end users to run with outdated images..

Is there any way to set that requirement? :-)

This is in the version of Ansible that Zuul runs, yeah ?

@Thulium-Drake
Copy link
Contributor Author

Yea, I check the collections repo, it was released in 1.14.0 (added with containers/ansible-podman-collections@2f5da14)

@dmsimard
Copy link
Contributor

According to the Zuul docs there is a job parameter that we can set to select the version of Ansible that the job should use: https://zuul-ci.org/docs/zuul/latest/config/job.html#attr-job.ansible-version

I don't know how to tell what versions of Ansible are available, though. We can try bumping it and see if it works.

When we needed to be strict about the version of Ansible that the job ran in the past, we'd use Zuul to install a specific version of Ansible in a virtualenv and then use that (nested) Ansible. This is what we do for the ara source repo.

I try to avoid doing that if we can since it adds a layer of complexity and "hides" the tasks from Zuul since the task essentially becomes an ansible-playbook command.

@Thulium-Drake
Copy link
Contributor Author

I checked the release notes for Ansible 9, assuming it's using the latest version, we should be good.

Also, Ansible 8's been deprecated a while now :-)

@dmsimard
Copy link
Contributor

Copy link

Zuul encountered a syntax error while parsing its
configuration in the repo ansible-community/ara-collection on branch master. The
problem was:

extra keys not allowed @ data['ansible_version']

The problem appears in the the "ara-role-api-podman" job stanza:

job:
name: ara-role-api-podman
parent: ara-role-integration-base
nodeset: ara-multinode
description: |
Desploys the ARA API server on Fedora 36 as well as CentOS Stream 8/9
in a Podman container and tests it using the default sqlite database backend.
run: tests/with_podman.yaml
ansible_version: '9'
...

in "ansible-community/ara-collection/.zuul.d/jobs.yaml@master", line 101

Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/f51a85019a794d87be6b6c10b9bf4589

✔️ ara-role-api-distributed-sqlite SUCCESS in 5m 50s
✔️ ara-role-api-mysql SUCCESS in 7m 16s
✔️ ara-role-api-postgresql SUCCESS in 7m 23s
✔️ ara-role-api-gunicorn-nginx SUCCESS in 5m 18s
✔️ ara-role-api-gunicorn-nginx-client-cert SUCCESS in 5m 07s
ara-role-api-podman FAILURE in 4m 26s
✔️ ara-role-api-fedora-packages SUCCESS in 5m 12s (non-voting)

@dmsimard
Copy link
Contributor

It's failing here now:

2024-10-30 10:04:43.082767 | TASK [ara_api : Ensure ARA API container]
2024-10-30 10:04:44.154077 | fedora-40 | ERROR
2024-10-30 10:04:44.154492 | fedora-40 | {
2024-10-30 10:04:44.154576 | fedora-40 |   "msg": "Can't pull image recordsansible/ara-api:latest"
2024-10-30 10:04:44.154631 | fedora-40 | }
failure
2024-10-30 10:04:44.302834 | centos-stream-9 | ERROR
2024-10-30 10:04:44.303076 | centos-stream-9 | {
2024-10-30 10:04:44.303133 | centos-stream-9 |   "msg": "Can't pull image recordsansible/ara-api:latest"
2024-10-30 10:04:44.303173 | centos-stream-9 | }

I suppose it should be fully qualified? like docker.io/recordsansible/ara-api or quay.io/recordsansible/ara-api.

@dmsimard
Copy link
Contributor

Almost there, maybe, it's now failing here:

2024-10-30 10:15:20.024029 | TASK [ara_api : Ensure ARA API container]
2024-10-30 10:15:29.344283 | centos-stream-9 | ERROR
2024-10-30 10:15:29.344686 | centos-stream-9 | {
2024-10-30 10:15:29.344754 | centos-stream-9 |   "msg": "Error writing systemd: [Errno 13] Permission denied: '/etc/systemd/system/ara-api.service'"
2024-10-30 10:15:29.344798 | centos-stream-9 | }
failure
2024-10-30 10:15:29.715629 | fedora-40 | ERROR
2024-10-30 10:15:29.715838 | fedora-40 | {
2024-10-30 10:15:29.715893 | fedora-40 |   "msg": "Error writing systemd: [Errno 13] Permission denied: '/etc/systemd/system/ara-api.service'"
2024-10-30 10:15:29.715932 | fedora-40 | }

Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/18018285f49b43069ffc697ce53d63b6

✔️ ara-role-api-distributed-sqlite SUCCESS in 6m 04s
✔️ ara-role-api-mysql SUCCESS in 7m 50s
✔️ ara-role-api-postgresql SUCCESS in 7m 03s
✔️ ara-role-api-gunicorn-nginx SUCCESS in 5m 19s
✔️ ara-role-api-gunicorn-nginx-client-cert SUCCESS in 4m 53s
ara-role-api-podman FAILURE in 4m 12s
✔️ ara-role-api-fedora-packages SUCCESS in 5m 04s (non-voting)

ara_api_log_dir: "/opt/ara/logs"
ara_api_settings: "{{ ara_api_root_dir }}/settings.yaml"

- name: Ensure ARA API container
Copy link
Contributor

Choose a reason for hiding this comment

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

There is kind of a gotcha here.

I think it is succeeding in starting the container when running from an unprivileged user (since podman can start rootless no problem) but then it tries to set up the systemd unit for it and fails due to lack of privileges.

If we set become: true on the task that starts the container, I would presume that it'd start it as root and not as the unprivileged user. It would work, but wouldn't be the same thing. If we go that route it would be worthy of being mentioned as a caveat since the pip/source installs supports running as unprivileged.

Note that there would also be a failure on the following task (service) since it doesn't have become: true.

@dmsimard
Copy link
Contributor

Some progress done but I am out of time for now, let me know what 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

Successfully merging this pull request may close these issues.

2 participants