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

fix: make tests work on fedora #269

Merged

Conversation

Al-Pragliola
Copy link
Contributor

fixes #268

Description

I set Privileged to true to test containers because SELinux prevented containers from reading metadata from the conn_config.pb file, which caused the container to use the in-memory database that does not persist data instead of the SQLite one, causing all tests to fail.

I also improved podman detection on systems that do not require a machine by adding a check to the DOCKER_HOST environment variable.

It's worth noting that I tried other ways to get it to work, both disabling Ryuk and trying to set different SELinux policies by following the testcontainers podman guide, but none of them worked.

How Has This Been Tested?

I tested this on my local machine by running make test

Merge criteria:

  • The commits and have meaningful messages; the author will squash them after approval or will ask to merge with squash.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Signed-off-by: Alessio Pragliola <seth.pro@gmail.com>
Signed-off-by: Alessio Pragliola <seth.pro@gmail.com>
Copy link
Member

@tarilabs tarilabs left a comment

Choose a reason for hiding this comment

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

thanks @Al-Pragliola for as well including documentation notes!

/lgtm

and planning to try it out locally asap to cross-check!
also if anyone else has chance to try it out on their system in the meantime :)

@@ -164,5 +166,5 @@ func tryDetectPodmanRunning() bool {
if err != nil {
return false
}
return info.Host.MachineState == "Running"
return info.Host.MachineState == "Running" || strings.Contains(os.Getenv("DOCKER_HOST"), "podman.sock")
Copy link
Member

Choose a reason for hiding this comment

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

I believe worth noting that this addition leverage a podman configuration which is not "docker compatibility".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for the OR is on Linux systems that do not need a machine to run containers.

@tarilabs
Copy link
Member

I'm hitting a rosetta error: unhandled auxillary vector type 28 and unable to double-check this PR locally atm.

btw @lampajr you were on Fedora too, did you needed this changes? 🤔 or maybe with docker engine it was not required ?

Copy link
Contributor

@isinyaaa isinyaaa left a comment

Choose a reason for hiding this comment

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

LGTM! but those instructions should apply to any OS in my experience.

Except of course for starting the socket, but that could be a footnote IMO, should be common sense on Linux.

CONTRIBUTING.md Outdated
Comment on lines 100 to 101
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock
export TESTCONTAINERS_RYUK_PRIVILEGED=true
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I have to do the same things to get podman working with testcontainers on MacOS, but I usually export

DOCKER_HOST=unix://$(podman machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}')

I wonder if it resolves to the same thing on Linux 👀

@tarilabs
Copy link
Member

fwiw works for me on Mac OSX back again with:

TESTCONTAINERS_RYUK_DISABLED=true make test-nocache

but not with

TESTCONTAINERS_RYUK_PRIVILEGED=true make test-nocache

but I'm also convinced is unrelated to this PR, confirming

/lgtm

@lampajr
Copy link
Member

lampajr commented Aug 21, 2024

btw @lampajr you were on Fedora too, did you needed this changes? 🤔 or maybe with docker engine it was not required ?

Yeah exactly I am on Fedora and I can confirm that with docker I did not have to add these changes (at least so far, I can give it another try in a week when I'll come back)

@lampajr
Copy link
Member

lampajr commented Aug 27, 2024

Yeah exactly I am on Fedora and I can confirm that with docker I did not have to add these changes (at least so far, I can give it another try in a week when I'll come back)

I can confirm this, with Docker none of those exports is required.

fwiw works for me on Mac OSX back again with:

TESTCONTAINERS_RYUK_DISABLED=true make test-nocache

but not with

TESTCONTAINERS_RYUK_PRIVILEGED=true make test-nocache

but I'm also convinced is unrelated to this PR, confirming

/lgtm

I just gave it a try and I can confirm the same results in my Fedora40: using TESTCONTAINERS_RYUK_DISABLED=true make test-nocache it works but using TESTCONTAINERS_RYUK_PRIVILEGED=true it does not.

I think it might be worth to mention it in the CONTRIBUTING.md as users might experience the same issues (given that I don't know why it is working differently)

CONTRIBUTING.md Outdated

```sh
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock
export TESTCONTAINERS_RYUK_PRIVILEGED=true
Copy link
Member

Choose a reason for hiding this comment

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

@Al-Pragliola can you kindly double-check if it's about TESTCONTAINERS_RYUK_PRIVILEGED or TESTCONTAINERS_RYUK_DISABLED, please?

see also: #269 (comment)

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 removed the export to privileged, I may have had an unclean state when I tested the feature, it works now just with the change I made in the code and the export to DOCKER_HOST.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

btw it works with either of them set to true or false

Signed-off-by: Alessio Pragliola <seth.pro@gmail.com>
Copy link
Member

@tarilabs tarilabs 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 re-checking @Al-Pragliola and for this doc and DX improvement!

/lgtm
/approve

@google-oss-prow google-oss-prow bot added the lgtm label Sep 11, 2024
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: isinyaaa, tarilabs

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow bot merged commit 9e024d2 into kubeflow:main Sep 11, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command make test not working with Fedora 40
4 participants