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

RHOAIENG-18459: chore(tests/containers/workbenches): make the ipv6 listening test work on macOS #868

Merged

Conversation

jiridanek
Copy link
Member

@jiridanek jiridanek commented Jan 27, 2025

follow-up for

Description

Uses the pydantic library to load output from podman machine info and sets-up a ssh tunnel from the podman machine vm to the machine running the test.

This is a workaround for macOS/rootful issues in Podman

How Has This Been Tested?

poetry run pytest tests/containers \
    -k 'TestWorkbenchImage and test_ipv6_only' \
    --image=quay.io/opendatahub/workbench-images:codeserver-ubi9-python-3.11-20250124-6a93e34

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • 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

@openshift-ci openshift-ci bot requested review from caponetto and harshad16 January 27, 2025 10:03
@openshift-ci openshift-ci bot added the size/l label Jan 27, 2025
@jiridanek jiridanek force-pushed the jd_initial_ipv6_w_macos branch from c3fb7f2 to 36045ab Compare January 27, 2025 10:04
@openshift-ci openshift-ci bot added size/l and removed size/l labels Jan 27, 2025
@jiridanek jiridanek force-pushed the jd_initial_ipv6_w_macos branch from 36045ab to d77fbda Compare January 27, 2025 10:10
@openshift-ci openshift-ci bot added size/l and removed size/l labels Jan 27, 2025
@jiridanek jiridanek added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jan 27, 2025
Copy link
Member Author

Choose a reason for hiding this comment

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

/override ci/prow/images
n/a

Copy link
Member Author

Choose a reason for hiding this comment

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

/override ci/prow/images
this is my override thread

Copy link
Contributor

openshift-ci bot commented Jan 27, 2025

@jiridanek: Overrode contexts on behalf of jiridanek: ci/prow/images

In response to this:

/override ci/prow/images
n/a

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@jstourac
Copy link
Member

/lgtm

# Usage example
if __name__ == "__main__":
tunnel_process = open_ssh_tunnel(
"podman-machine-default",
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure of a good/right place to document this.. but we should ideally call out (for purposes of running locally) - we require a machine named podman-machine-default to exist. I realize it errors after the fact appropriately in this script... but this is codifying a requirement worth calling out in a readme or something maybe?

(as a case in point - I don't (as of now - but will soon!) have a podman-machine-default machine - as its too underpowered to run many notebooks)

Copy link
Member Author

Choose a reason for hiding this comment

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

so, you have a differently named podman machine? in that case this should probably detect whatever machine you're using and use that, wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, perhaps if we just had the system choose the currently active connection - that makes it "one less stumbling block"

➜ ~/ $ podman system connection ls
Name                URI                                                         Identity                                                        Default     ReadWrite
rhoai-default       ssh://core@127.0.0.1:50943/run/user/501/podman/podman.sock  /Users/astonebe/.local/share/containers/podman/machine/machine  false       true
rhoai-default-root  ssh://root@127.0.0.1:50943/run/podman/podman.sock           /Users/astonebe/.local/share/containers/podman/machine/machine  true        true

seems podman system connection ls can give you a data structure that lists which machine is currently default

Copy link
Member Author

Choose a reason for hiding this comment

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

very good point, I added a commit here that addresses that; I look what the realpath docker_socket is, and compare that with the sockets given in podman machine info. I did not need podman system connections ls after all

Copy link
Member Author

Choose a reason for hiding this comment

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

And, turned out this does not really fix anything with 1+ podman machines present. That's because podman machine inspect without machine name inspects the default machine only. Followup pr needed.

@@ -0,0 +1,41 @@
from pydantic import BaseModel
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you look into https://podman-py.readthedocs.io/en/stable/index.html ? Can we get some of this boilerplate "for free" if we use the Podman Python SDK? (or, conversely, is the Podman Python SDK "more hassle than its worth" ?)

Copy link
Member Author

Choose a reason for hiding this comment

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

there's quite a lot of various docker/podman libraries like this

since I went with testcontainers (which uses docker-py) originally, I intended to keep to docker-compatible apis; but, turns out, more is oftentimes needed

besides testcontainers, there's all that Adriel mentioned at one of the qe meetings

there are other stuff, for example something from red hat people that runs podman commands as a subprocess; so whatever you script in python, you have an obvious way to reproduce on commandline

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that podman machine api is exposed there... but I'd have to check more thoroughly to find out.

I spent few minutes and no joy so far. I really think podman-machine not part of the libpod api.

Copy link
Contributor

Choose a reason for hiding this comment

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

totally fine - not worth spending much time on it - appreciate you sharing thoughts/motivation behind the question... you can consider this conversation resolved.

Copy link
Member Author

Choose a reason for hiding this comment

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

it's a good thought, cc @jstourac maybe we'd just stop pretending we use docker and will fully embrace podman

there's also https://issues.redhat.com/browse/RHOAIENG-18060 that asks to write these test so that they can be run on docker/podman and also openshift; that's gonna be another challenge, but maybe a lesser one than all this macOS stuff

…dling: detect the right one to use if user has multiple machines around
@jiridanek jiridanek added tide/merge-method-rebase Denotes a PR that should be rebased by tide when it merges. and removed tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. labels Jan 27, 2025
Copy link
Contributor

openshift-ci bot commented Jan 27, 2025

@jiridanek: Overrode contexts on behalf of jiridanek: ci/prow/images

In response to this:

/override ci/prow/images
this is my override thread

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@daniellutz
Copy link
Contributor

I tested here and looks good!

/lgtm

@andyatmiami
Copy link
Contributor

andyatmiami commented Jan 27, 2025

/lgtm

I have confirmed if I have a machine named podman-machine-default - the given test command succeeds:

poetry run pytest tests/containers \
    -k 'TestWorkbenchImage and test_ipv6_only' \
    --image=quay.io/opendatahub/workbench-images:codeserver-ubi9-python-3.11-20250124-6a93e34
...
PASSEDDEBUG:urllib3.connectionpool:http://localhost:None "DELETE /v1.41/networks/e252ab284eaa64991cb4b40e68e99cd337f9723544d308caadd7de65b0a6c215 HTTP/1.1" 204 0


=================================================================================================== 1 passed, 4 deselected in 199.02s (0:03:19) ===================================================================================================

ℹ️ I am on MacOS

@jiridanek
Copy link
Member Author

/approve

Copy link
Contributor

openshift-ci bot commented Jan 27, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jiridanek

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

@openshift-merge-bot openshift-merge-bot bot merged commit 9e76f6f into opendatahub-io:main Jan 27, 2025
7 checks passed
@jiridanek jiridanek deleted the jd_initial_ipv6_w_macos branch January 27, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm size/l tide/merge-method-rebase Denotes a PR that should be rebased by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants