Skip to content

feat(install): Adds support for podman(compose) #3673

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Conversation

DuncanConroy
Copy link

Adds support for podman(compose), while maintaining compatibility with docker

Introduces a new script to detect podman vs. docker. Distinguishes between docker and podman minimum versions and substitutes uses of docker with a variable instead.

Closes #369

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Copy link
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

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

Quite surprised (positively!) that the changes needed are so few! Added a few comments and on top of those, we definitely should have a test using podman now to make sure this actually works and does not break in the future (can help with this if you need me).

Thanks so much for taking the effort!

Copy link
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

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

Oops, sorry meant the require changes 😅

@BYK
Copy link
Member

BYK commented Apr 22, 2025

FYI tests failed with the following error:

Detecting Docker platform
FAIL: Unsupported docker architecture amd64.

@DuncanConroy
Copy link
Author

Quite surprised (positively!) that the changes needed are so few! Added a few comments and on top of those, we definitely should have a test using podman now to make sure this actually works and does not break in the future (can help with this if you need me).

Thanks so much for taking the effort!

I agree that having a test would be great. In the best case, we can run the whole suite for both docker and podman. I'm just unsure about the environment this is run on and would welcome your input and ideas very much!

@DuncanConroy DuncanConroy marked this pull request as draft April 23, 2025 13:03
@DuncanConroy
Copy link
Author

Have converted back to draft, as there are some tweaks to make, still.

@aldy505
Copy link
Collaborator

aldy505 commented Apr 23, 2025

@DuncanConroy Let us know if you need help in terms of anything, we'd be happy to help you. Having this PR really made us happy :)

Copy link
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

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

Tests are run on GitHub Actions. I'm happy to add a new job that installs and runs with podman once the PR is stable in terms of API

@@ -29,6 +29,8 @@ Options:
--no-report-self-hosted-issues
Do not report error and performance data about your
self-hosted instance upstream to Sentry.
--container-engine-podman
Copy link
Member

Choose a reason for hiding this comment

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

Same as above: how about this just being --container-engine with a default value of docker?

Copy link
Author

Choose a reason for hiding this comment

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

Not sure I understand your intent. This was thought as a switch to activate podman over docker. We can surely remove the autodetection and completely rely on this switch. I'd still keep it --container-engine-podman, because just using --container-engine would possibly be misleading?

Copy link
Member

Choose a reason for hiding this comment

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

@DuncanConroy sorry for not being clearer. What I had in mind was making --container-engine a flag to pass in a custom value as in --container-engine <engine> where we default to docker (so when the flag is not passed, we will assume docker).

Although we would only support podman and docker at start, this should keep the API unchanged if we ever add new engines like runc or similar.

Copy link
Author

Choose a reason for hiding this comment

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

Not sure how to do this with bash, tbh. :D

Copy link
Member

Choose a reason for hiding this comment

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

I'll see what I can do about this 😅

Choose a reason for hiding this comment

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

It is quite simple... unless you want to validate argument :)
Something like

  case "$1" in

<...>

  --container-engine) CONTAINER_ENGINE="$2"; shift ;;

Copy link
Collaborator

@aminvakil aminvakil left a comment

Choose a reason for hiding this comment

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

Thank you for this!

sentry-admin.sh file needs to be fixed as well, I guess adding source install/detect-container-engine.sh suffices.

@BYK
Copy link
Member

BYK commented Apr 29, 2025

@DuncanConroy podman compose run calls add a weird hash at the beginning (see https://github.com/getsentry/self-hosted/actions/runs/14732417876/job/41349793317?pr=3673#step:4:890)

Any idea how to suppress that?

@DuncanConroy
Copy link
Author

@DuncanConroy podman compose run calls add a weird hash at the beginning (see https://github.com/getsentry/self-hosted/actions/runs/14732417876/job/41349793317?pr=3673#step:4:890)

Any idea how to suppress that?

I suppose you mean the hash that's written to the credentials.json file before the JSON? I don't have a clue, unfortunately. Didn't encounter that myself.

@aldy505
Copy link
Collaborator

aldy505 commented Apr 29, 2025

Sorry for the late reply. There were some changes waiting in my commit list. As I was testing this in an air-gapped environment, it wasn't as straight forward.

@DuncanConroy I wonder how did you manage to test this Podman Compose thing on air-gapped environment?

Built the docker images locally on my machine, then used docker save to export them to .tar, as mentioned in the docs. Copied them over to the machine and imported the images over there. Getting this up and running on RHEL with SeLinux was also quite a challenge with many manual steps. I've created another branch air-gapped in my forked repo, but that's far from production ready and doesn't include the manual steps for SeLinux. Feel free to have a look.

I'm more interested on your war story with SELinux. I'd appreciate it if you share that with us later. Also, I'm glad the docker save thing did it for you, I was the one who wrote that docs 😆

Unfortunately, we didn't quite got replays to work, which was the main reason we tried sentry. And as we had a very restricted network and policies, there was no option to use the cloud version.

We'll help you on that. My hunch is related to COMPOSE_PROFILE that should be feature-complete. Session Replays is one of the easiest feature to enable.

@DuncanConroy
Copy link
Author

DuncanConroy commented Apr 30, 2025 via email

@BYK
Copy link
Member

BYK commented May 6, 2025

FYI I put this on hold on my end folks as I spent way too much time fixing these scripts and CI.

If anyone can figure out why we are getting that hash, I think that would unblock most of this.

@doc-sheet
Copy link

@DuncanConroy podman compose run calls add a weird hash at the beginning (see getsentry/self-hosted/actions/runs/14732417876/job/41349793317?pr=3673#step:4:890)

Any idea how to suppress that?

@BYK, could you run it again with debug on?

I want to participate in fixes and believe it would be faster then recreating environment by myself from the ground.

@BYK
Copy link
Member

BYK commented May 6, 2025

@doc-sheet you mean GitHub CI debug? Because I'm fairly sure the debug for the tooling will generate output that would break things even further.

Btw the setup is fairly bare bones: Ubuntu 22.04 with podman stuff installed. Clone the repo, run install.sh. That's all

@doc-sheet
Copy link

yeah, I meant github action restart with debug option

@doc-sheet
Copy link

doc-sheet commented May 6, 2025

Just made a quick look and found a fun thing.
When I added --verbose flag error is gone.

I suppose it somehow related to how python (podman-compose) parses arguments. Maybe it adds detach flag at some point which is why podman prints container id.

I'll try to dig in it tomorrow.

I also stepped on another issue:

podman compose --no-ansi --env-file .env build --build-arg http_proxy= --build-arg https_proxy= --build-arg no_proxy= '--podman-rm-args='\''--force'\''' web

  podman-compose: error: unrecognized arguments: --podman-rm-args='--force'

@BYK
Copy link
Member

BYK commented May 6, 2025

Could that issue be related to containers/podman-compose#707 ?

@BYK
Copy link
Member

BYK commented May 6, 2025

@doc-sheet here's the run with debug enabled: https://github.com/getsentry/self-hosted/actions/runs/14732867860/job/41748307991?pr=3673

Thanks so much for your help 🙏🏻

@aldy505
Copy link
Collaborator

aldy505 commented May 7, 2025

FYI I put this on hold on my end folks as I spent way too much time fixing these scripts and CI.

If anyone can figure out why we are getting that hash, I think that would unblock most of this.

Me and Amin don't have write access, sooo..... 🤷

$dcb --force-rm web
dcb_force="$dcb --force-rm"
if [[ "$CONTAINER_ENGINE" == "podman" ]]; then
dcb_force="$dcb --podman-rm-args='--force'"

Choose a reason for hiding this comment

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

looks like single quotes here passed as is which leads to

dcb_force='podman compose --no-ansi --env-file .env build --build-arg http_proxy= --build-arg https_proxy= --build-arg no_proxy= --podman-rm-args='\''--force'\'''

podman compose --no-ansi --env-file .env build --build-arg http_proxy= --build-arg https_proxy= --build-arg no_proxy= '--podman-rm-args='\''--force'\''' web

podman-compose: error: unrecognized arguments: --podman-rm-args='--force'

@doc-sheet
Copy link

Sooo. The issue is not in args.

How podman compose run works:

  1. Creates pod if not exists
  2. Runs container in that pod

podman compose --no-ansi --env-file .env run --rm --no-deps -T relay credentials generate --stdout
if actually a set of commands:

podman pod exists pod_sentry-self-hosted
podman pod create --name=pod_sentry-self-hosted --infra=false --share=
podman run --name=sentry-self-hosted_relay_tmp61537 --rm -i --pod=pod_sentry-self-hosted --label io.podman.compose.config-hash=4f24dfaedb436ac5a872aaf9afd02b3d5da8c0913de8c33c0ee702a9700764db --label io.podman.compose.project=sentry-self-hosted --label io.podman.compose.version=1.3.0 --label PODMAN_SYSTEMD_UNIT=podman-compose@sentry-self-hosted.service --label com.docker.compose.project=sentry-self-hosted --label com.docker.compose.project.working_dir=/home/runner/work/self-hosted/self-hosted --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=relay -v ./relay:/work/.relay:ro -v ./geoip:/geoip:ro --network=sentry-self-hosted_default:alias=relay getsentry/relay:nightly credentials generate --stdout

So hash is the id of created pod written to stdout after podman pod create

@doc-sheet
Copy link

I guess fastest way to handle this is to just disable pod creation

"Ensuring Relay credentials" test passed.

However to someone who would use podman-compose to run sentry pods may be neccessary (idk, never used it).

--- a/install/dc-detect-version.sh
+++ b/install/dc-detect-version.sh
@@ -66,7 +66,7 @@ fi
 proxy_args="--build-arg http_proxy=${http_proxy:-} --build-arg https_proxy=${https_proxy:-} --build-arg no_proxy=${no_proxy:-}"
 if [[ "$CONTAINER_ENGINE" == "podman" ]]; then
   proxy_args_dc="--podman-build-args http_proxy=${http_proxy:-},https_proxy=${https_proxy:-},no_proxy=${no_proxy:-}"
-  dcr="$dc run --rm"
+  dcr="$dc --in-pod=false run --rm"
 else
   proxy_args_dc=$proxy_args
   dcr="$dc run --pull=never --rm"

@doc-sheet
Copy link

Another workaround I guess is to run dummy command like

$dcr --no-deps -T relay --version >/dev/null

just to create pod, so next command will run in existing pod and would not print it's id

@BYK
Copy link
Member

BYK commented May 7, 2025

@doc-sheet ah, great find! The $dcr shortcut is only for one-off commands so disabling pod creation for that makes the most sense to me. I'll make the change and see if it passes the tests.

@BYK
Copy link
Member

BYK commented May 7, 2025

We should also figure out volume caching story with Podman. We have 2 options:

  • Use podman volume export and podman volume import. This looks neat but requires us to do very podman-specific things in the CI and probably duplicate the cache
  • Move the cached Docker volumes over to Podman as suggested here: https://www.reddit.com/r/podman/comments/15j7vhn/comment/juys1of/ -- This feels a bit hacky/finnicky but if it works, I'll take it

@BYK
Copy link
Member

BYK commented May 7, 2025

Okay, now we need to make the tests aware of Podman

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Support Podman (and Podman Compose)
5 participants