Skip to content

Commit a818657

Browse files
authored
Merge pull request #2685 from red-hat-data-services/fix/rhoai-2.25-openshift-rstudio-probe
fix(tests): probe / instead of /api for OpenShift port-forward readiness
2 parents 7cc120e + a624f5a commit a818657

2 files changed

Lines changed: 86 additions & 3 deletions

File tree

.github/workflows/test-containers.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,76 @@ jobs:
158158
with:
159159
token: ${{ secrets.CODECOV_TOKEN }}
160160
files: junit.xml
161+
162+
openshift-container-tests:
163+
name: "openshift: ${{ matrix.name }}"
164+
needs: find-images
165+
runs-on: ubuntu-26.04
166+
strategy:
167+
fail-fast: false
168+
matrix: ${{ fromJSON(needs.find-images.outputs.matrix) }}
169+
steps:
170+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
171+
with:
172+
persist-credentials: false
173+
174+
- name: Install uv
175+
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
176+
with:
177+
version-file: pyproject.toml
178+
enable-cache: true
179+
cache-dependency-glob: "uv.lock"
180+
181+
- name: Install Python
182+
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
183+
with:
184+
python-version: "3.14"
185+
186+
- name: Install deps
187+
run: uv sync --locked
188+
189+
# Rootful podman sharing image storage with cri-o, same as build-notebooks-TEMPLATE.yaml,
190+
# so the pod created by the openshift-marked tests can find the image without re-pulling.
191+
- name: Install and configure Podman
192+
uses: './.github/actions/install-podman-action'
193+
with:
194+
platform: linux/amd64
195+
196+
- name: Provision K8s cluster
197+
uses: ./.github/actions/provision-k8s
198+
199+
- name: Login to GHCR
200+
uses: docker/login-action@371161bbe7024a29a25c5e19bfcbc0804fe9ad2c # v4.5.2
201+
with:
202+
registry: ghcr.io
203+
username: ${{ github.actor }}
204+
password: ${{ secrets.GITHUB_TOKEN }}
205+
206+
# install-podman-action's storage.conf enables zstd:chunked partial pulls, which
207+
# only matters for `podman build`'s own registry pulls elsewhere. Here we `podman
208+
# pull` an already-published ghcr.io image, and ghcr.io's blob endpoint returns
209+
# "501 Unsupported client range" for partial/ranged fetches, failing the pull
210+
# outright instead of falling back to a full one. Disable it for this job only.
211+
- name: Disable zstd:chunked partial image pulls
212+
run: sudo sed -i 's/enable_partial_images = "true"/enable_partial_images = "false"/' /etc/containers/storage.conf
213+
214+
- name: Pull and run OpenShift container tests
215+
env:
216+
TEST_IMAGE: ${{ matrix.image }}
217+
DOCKER_HOST: "unix:///var/run/podman/podman.sock"
218+
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE: "/var/run/podman/podman.sock"
219+
run: |
220+
set -Eeuxo pipefail
221+
podman pull "${TEST_IMAGE}"
222+
uv run pytest --capture=fd tests/containers \
223+
-m 'openshift and not cuda and not rocm' \
224+
--image="${TEST_IMAGE}" \
225+
--junitxml=junit-openshift.xml \
226+
-v
227+
228+
- name: Upload test results
229+
if: ${{ !cancelled() }}
230+
uses: codecov/test-results-action@0fa95f0e1eeaafde2c782583b36b28ad0d8c77d3 # v1.2.1
231+
with:
232+
token: ${{ secrets.CODECOV_TOKEN }}
233+
files: junit-openshift.xml

tests/containers/kubernetes_utils.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,22 @@ def deploy(
267267

268268
self.port = p.get_actual_port()
269269
LOGGER.debug(f"Listening on port {self.port}")
270-
# Use 120s timeout for slower cold starts (e.g. code-server on arm64).
270+
271+
# Use TIMEOUT_2MIN for slower cold starts (e.g. code-server on arm64).
272+
# Always probe / (not /api): RStudio's nginx redirects /api to a
273+
# hardcoded http://127.0.0.1:8888/api/, which is wrong (and unreachable)
274+
# through a port-forward where the local port isn't literally 8888.
275+
# https://github.com/red-hat-data-services/notebooks/issues/2684
276+
def _ready() -> bool:
277+
with requests.Session() as session:
278+
response = session.get(f"http://127.0.0.1:{self.port}/", timeout=5, allow_redirects=True)
279+
return response.status_code == 200
280+
271281
Wait.until(
272282
"Connecting to pod succeeds",
273283
1,
274-
120,
275-
lambda: requests.get(f"http://127.0.0.1:{self.port}/api", timeout=10).status_code == 200,
284+
TestFrameConstants.TIMEOUT_2MIN,
285+
_ready,
276286
)
277287
LOGGER.debug("Done setting up portforward")
278288

0 commit comments

Comments
 (0)