Skip to content

Commit 43152d6

Browse files
authored
Merge branch 'main' into support_build_push
2 parents de4567b + dd0335c commit 43152d6

File tree

8 files changed

+54
-24
lines changed

8 files changed

+54
-24
lines changed

.github/workflows/add-remove-labels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

4343
- name: Run add remove labels
4444
env:
45-
GITHUB_TOKEN: ${{ secrets.OPENDATAHUB_TESTS_BOT_PAT }}
45+
GITHUB_TOKEN: ${{ secrets.RHODS_CI_BOT_PAT }}
4646
GITHUB_PR_NUMBER: "${{ github.event.pull_request.number || github.event.issue.number }}"
4747
GITHUB_EVENT_ACTION: ${{ github.event.action }}
4848
GITHUB_EVENT_REVIEW_STATE: ${{ github.event.review.state }}

.github/workflows/cherry-pick-comment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
- name: Checkout the latest code
1818
uses: actions/checkout@v4
1919
with:
20-
token: ${{ secrets.OPENDATAHUB_TESTS_BOT_PAT }}
20+
token: ${{ secrets.RHODS_CI_BOT_PAT }}
2121
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
2222
- name: Automatic Cherry Pick
2323
uses: dbasunag/cherry-pick-pr@master
2424
env:
25-
GITHUB_TOKEN: ${{ secrets.OPENDATAHUB_TESTS_BOT_PAT }}
25+
GITHUB_TOKEN: ${{ secrets.RHODS_CI_BOT_PAT }}

.github/workflows/on-review-add-label.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ jobs:
8383
uses: astral-sh/setup-uv@v6
8484
- name: 'Run add-remove-labels action'
8585
env:
86-
GITHUB_TOKEN: ${{ secrets.OPENDATAHUB_TESTS_BOT_PAT }}
86+
GITHUB_TOKEN: ${{ secrets.RHODS_CI_BOT_PAT }}
8787
GITHUB_EVENT_NAME: ${{ needs.download_context_artifact.outputs.event_name }}
8888
run: uv run python .github/workflows/scripts/pr_workflow.py

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ repos:
3535
- id: detect-secrets
3636

3737
- repo: https://github.com/astral-sh/ruff-pre-commit
38-
rev: v0.11.7
38+
rev: v0.11.8
3939
hooks:
4040
- id: ruff
4141
- id: ruff-format
@@ -49,7 +49,7 @@ repos:
4949
# - id: renovate-config-validator
5050

5151
- repo: https://github.com/gitleaks/gitleaks
52-
rev: v8.24.3
52+
rev: v8.25.1
5353
hooks:
5454
- id: gitleaks
5555

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ dependencies = [
6363
"timeout-sampler>=1.0.6",
6464
"shortuuid>=1.0.13",
6565
"jira>=3.8.0",
66-
"openshift-python-wrapper>=11.0.38",
66+
"openshift-python-wrapper>=11.0.50",
6767
"semver>=3.0.4",
6868
"pytest-order>=1.3.0",
6969
"marshmallow==3.26.1,<4", # this version is needed for pytest-jira

tests/workbenches/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def default_notebook(
8383

8484
# Set the correct username
8585
username = get_username(dyn_client=admin_client)
86+
assert username, "Failed to determine username from the cluster"
8687

8788
# Set the image path based on internal image registry status
8889
minimal_image_path = (

tests/workbenches/utils.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1-
from kubernetes.dynamic import DynamicClient, Resource, ResourceInstance
1+
from kubernetes.dynamic import DynamicClient
2+
from ocp_resources.self_subject_review import SelfSubjectReview
3+
from ocp_resources.user import User
4+
from simple_logger.logger import get_logger
25

6+
LOGGER = get_logger(name=__name__)
37

4-
def get_username(dyn_client: DynamicClient) -> str:
8+
9+
def get_username(dyn_client: DynamicClient) -> str | None:
510
"""Gets the username for the client (see kubectl -v8 auth whoami)"""
6-
self_subject_review_resource: Resource = dyn_client.resources.get(
7-
api_version="authentication.k8s.io/v1", kind="SelfSubjectReview"
8-
)
9-
self_subject_review: ResourceInstance = dyn_client.create(self_subject_review_resource)
10-
username: str = self_subject_review.status.userInfo.username
11+
username: str | None
12+
try:
13+
self_subject_review = SelfSubjectReview(client=dyn_client, name="selfSubjectReview").create()
14+
assert self_subject_review
15+
username = self_subject_review.status.userInfo.username
16+
except NotImplementedError:
17+
LOGGER.info(
18+
"SelfSubjectReview not found. Falling back to user.openshift.io/v1/users/~ for OpenShift versions <=4.14"
19+
)
20+
user = User(client=dyn_client, name="~").instance
21+
username = user.get("metadata", {}).get("name", None)
22+
1123
return username

utilities/infra.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -851,16 +851,33 @@ def wait_for_isvc_pods(client: DynamicClient, isvc: InferenceService, runtime_na
851851
return get_pods_by_isvc_label(client=client, isvc=isvc, runtime_name=runtime_name)
852852

853853

854-
def verify_dsci_status_ready(dsci_resource: DSCInitialization) -> None:
855-
LOGGER.info(f"Verify DSCI {dsci_resource.name} are {dsci_resource.Status.READY}.")
856-
if dsci_resource.status != dsci_resource.Status.READY:
857-
raise ResourceNotReadyError(f"DSCI {dsci_resource.name} is not ready.\nStatus: {dsci_resource.instance.status}")
854+
@retry(
855+
wait_timeout=120,
856+
sleep=5,
857+
exceptions_dict={ResourceNotReadyError: []},
858+
)
859+
def wait_for_dsci_status_ready(dsci_resource: DSCInitialization) -> bool:
860+
LOGGER.info(f"Wait for DSCI {dsci_resource.name} to be in {dsci_resource.Status.READY} status.")
861+
if dsci_resource.status == dsci_resource.Status.READY:
862+
return True
863+
864+
raise ResourceNotReadyError(
865+
f"DSCI {dsci_resource.name} is not ready.\nCurrent status: {dsci_resource.instance.status}"
866+
)
858867

859868

860-
def verify_dsc_status_ready(dsc_resource: DataScienceCluster) -> None:
861-
LOGGER.info(f"Verify DSC {dsc_resource.name} are {dsc_resource.Status.READY}.")
862-
if dsc_resource.status != dsc_resource.Status.READY:
863-
raise ResourceNotReadyError(f"DSC {dsc_resource.name} is not ready.\nStatus: {dsc_resource.instance.status}")
869+
@retry(
870+
wait_timeout=120,
871+
sleep=5,
872+
exceptions_dict={ResourceNotReadyError: []},
873+
)
874+
def wait_for_dsc_status_ready(dsc_resource: DataScienceCluster) -> bool:
875+
LOGGER.info(f"Wait for DSC {dsc_resource.name} are {dsc_resource.Status.READY}.")
876+
if dsc_resource.status == dsc_resource.Status.READY:
877+
return True
878+
raise ResourceNotReadyError(
879+
f"DSC {dsc_resource.name} is not ready.\nCurrent status: {dsc_resource.instance.status}"
880+
)
864881

865882

866883
def verify_cluster_sanity(
@@ -898,8 +915,8 @@ def verify_cluster_sanity(
898915
LOGGER.warning(f"Skipping RHOAI resource checks, got {skip_rhoai_check}")
899916

900917
else:
901-
verify_dsci_status_ready(dsci_resource=dsci_resource)
902-
verify_dsc_status_ready(dsc_resource=dsc_resource)
918+
wait_for_dsci_status_ready(dsci_resource=dsci_resource)
919+
wait_for_dsc_status_ready(dsc_resource=dsc_resource)
903920

904921
except (ResourceNotReadyError, NodeUnschedulableError, NodeNotReadyError) as ex:
905922
error_msg = f"Cluster sanity check failed: {str(ex)}"

0 commit comments

Comments
 (0)