Skip to content

[MR updates] use client arg for resource calls#983

Merged
dbasunag merged 1 commit intoopendatahub-io:mainfrom
dbasunag:update_client_part1
Jan 7, 2026
Merged

[MR updates] use client arg for resource calls#983
dbasunag merged 1 commit intoopendatahub-io:mainfrom
dbasunag:update_client_part1

Conversation

@dbasunag
Copy link
Copy Markdown
Collaborator

@dbasunag dbasunag commented Jan 5, 2026

Description

How Has This Been Tested?

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

Summary by CodeRabbit

Release Notes

  • Tests
    • Improved test infrastructure by standardizing resource client management across model registry, authentication, and security context test fixtures for enhanced reliability and consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 5, 2026

📝 Walkthrough

Walkthrough

The PR updates test fixture and utility functions to consistently pass an admin_client (DynamicClient) parameter to resource constructors across multiple test modules. Resources including Namespace, Secret, OAuth, ModelRegistry, Deployment, and CustomResourceDefinition are instantiated with client=admin_client instead of relying on default clients.

Changes

Cohort / File(s) Summary
Main conftest fixtures
tests/model_registry/conftest.py
Updated multiple fixtures to accept and pass admin_client: DynamicClient parameter: created_htpasswd_secret, updated_oauth_config, model_registry_instance, and model_registry_metadata_db_resources. All Namespace, Secret, OAuth, ModelRegistry, PersistentVolumeClaim, Service, ConfigMap, and Deployment constructors now include client=admin_client.
SCC conftest fixtures
tests/model_registry/scc/conftest.py
Added admin_client: DynamicClient parameter to model_registry_scc_namespace and deployment_model_registry_ns fixtures. Namespace and Deployment constructors updated to use client=admin_client.
SCC utility functions
tests/model_registry/scc/utils.py
Updated get_pod_by_deployment_name() to pass client=admin_client when constructing Deployment.
Upgrade test module
tests/model_registry/model_registry/upgrade/test_model_registry_upgrade.py
Updated CustomResourceDefinition instantiation to include client=admin_client parameter.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[MR updates] use client arg for resource calls' directly relates to the main change: systematically updating resource constructors to accept and use a client (admin_client) parameter across test fixtures and resource creation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/model_registry/conftest.py (1)

570-570: Remove unused original_user parameter.

The original_user parameter is declared in the function signature but never used in the function body. Consider removing it to clean up the API.

🔎 Proposed fix
 @pytest.fixture(scope="module")
 def created_htpasswd_secret(
-    is_byoidc: bool, admin_client: DynamicClient, original_user: str, user_credentials_rbac: dict[str, str]
+    is_byoidc: bool, admin_client: DynamicClient, user_credentials_rbac: dict[str, str]
 ) -> Generator[UserTestSession | None, None, None]:

Based on static analysis hints.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b22967e and c7a177f.

📒 Files selected for processing (4)
  • tests/model_registry/conftest.py
  • tests/model_registry/scc/conftest.py
  • tests/model_registry/scc/utils.py
  • tests/model_registry/upgrade/model_registry/test_model_registry_upgrade.py
🧰 Additional context used
🧬 Code graph analysis (3)
tests/model_registry/scc/conftest.py (2)
tests/conftest.py (1)
  • admin_client (79-80)
tests/model_registry/conftest.py (1)
  • model_registry_namespace (76-77)
tests/model_registry/scc/utils.py (1)
tests/conftest.py (1)
  • admin_client (79-80)
tests/model_registry/conftest.py (2)
utilities/resources/model_registry_modelregistry_opendatahub_io.py (1)
  • ModelRegistry (9-94)
tests/conftest.py (2)
  • admin_client (79-80)
  • original_user (819-822)
🪛 Ruff (0.14.10)
tests/model_registry/conftest.py

570-570: Unused function argument: original_user

(ARG001)

🔇 Additional comments (9)
tests/model_registry/upgrade/model_registry/test_model_registry_upgrade.py (1)

112-112: LGTM! Client parameter correctly added to CustomResourceDefinition.

The explicit client parameter aligns with the broader pattern of centralizing DynamicClient usage across resource constructors.

tests/model_registry/conftest.py (5)

91-93: LGTM! ModelRegistry correctly receives client parameter.

The explicit client parameter follows the established pattern for post-upgrade resource instantiation.


135-161: LGTM! All post-upgrade resources correctly instantiated with client parameter.

The consistent pattern of passing client=admin_client to Secret, PersistentVolumeClaim, Service, ConfigMap, and Deployment constructors aligns with the PR's objective.


251-253: LGTM! Namespace instantiation correctly updated with client parameter.

Both Namespace instantiations (custom namespace creation and original namespace restoration) now properly receive the admin_client parameter.

Also applies to: 270-270


586-586: LGTM! Secret constructor correctly receives client parameter.

The explicit client parameter ensures proper API context for secret creation in the openshift-config namespace.


607-607: LGTM! OAuth constructor correctly receives client parameter.

The explicit client parameter aligns with the broader pattern of centralizing DynamicClient usage.

tests/model_registry/scc/utils.py (1)

93-93: LGTM! Deployment constructor correctly receives client parameter.

The explicit client parameter ensures proper API context when verifying deployment existence.

tests/model_registry/scc/conftest.py (2)

35-36: LGTM! Fixture correctly updated to accept and use admin_client.

The explicit client parameter ensures proper API context when retrieving namespace annotations for SCC validation.


44-52: LGTM! Fixture correctly updated to accept and use admin_client.

The explicit client parameter ensures proper API context when instantiating the Deployment resource for testing.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 5, 2026

The following are automatically added/executed:

  • PR size label.
  • Run pre-commit
  • Run tox
  • Add PR author as the PR assignee
  • Build image based on the PR

Available user actions:

  • To mark a PR as WIP, add /wip in a comment. To remove it from the PR comment /wip cancel to the PR.
  • To block merging of a PR, add /hold in a comment. To un-block merging of PR comment /hold cancel.
  • To mark a PR as approved, add /lgtm in a comment. To remove, add /lgtm cancel.
    lgtm label removed on each new commit push.
  • To mark PR as verified comment /verified to the PR, to un-verify comment /verified cancel to the PR.
    verified label removed on each new commit push.
  • To Cherry-pick a merged PR /cherry-pick <target_branch_name> to the PR. If <target_branch_name> is valid,
    and the current PR is merged, a cherry-picked PR would be created and linked to the current PR.
  • To build and push image to quay, add /build-push-pr-image in a comment. This would create an image with tag
    pr-<pr_number> to quay repository. This image tag, however would be deleted on PR merge or close action.
Supported labels

{'/hold', '/wip', '/lgtm', '/cherry-pick', '/build-push-pr-image', '/verified'}

@dbasunag dbasunag force-pushed the update_client_part1 branch from c7a177f to 24dd1fc Compare January 7, 2026 12:34
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/model_registry/conftest.py (1)

62-134: Inconsistent client usage in cleanup block.

Lines 88 and 105-107 correctly use client=admin_client for Namespace instantiation. However, the finally block at lines 122 and 124 instantiates Namespace objects without the client parameter, relying on default client behavior. This inconsistency could lead to issues if the default client differs from admin_client.

🔧 Proposed fix to use consistent client parameter
         finally:
             resource_editor.restore()
-            Namespace(name=py_config["model_registry_namespace"]).delete(wait=True)
+            Namespace(client=admin_client, name=py_config["model_registry_namespace"]).delete(wait=True)
             # create the original namespace object again, so that we can wait for it to be created first
-            original_namespace = Namespace(name=original_namespace_name, wait_for_resource=True)
+            original_namespace = Namespace(client=admin_client, name=original_namespace_name, wait_for_resource=True)
             original_namespace.wait_for_status(status=Namespace.Status.ACTIVE)
🤖 Fix all issues with AI agents
In @tests/model_registry/conftest.py:
- Around line 204-206: The function signature for created_htpasswd_secret
includes an unused parameter original_user; remove original_user from the
parameter list and update any call sites to stop passing that argument (or
adjust callers accordingly), ensuring the function created_htpasswd_secret now
accepts only is_byoidc: bool, admin_client: DynamicClient,
user_credentials_rbac: dict[str, str] and that type hints and any references to
original_user inside tests or fixtures are removed/updated.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7a177f and 24dd1fc.

📒 Files selected for processing (4)
  • tests/model_registry/conftest.py
  • tests/model_registry/model_registry/upgrade/test_model_registry_upgrade.py
  • tests/model_registry/scc/conftest.py
  • tests/model_registry/scc/utils.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/model_registry/scc/conftest.py
🧰 Additional context used
🧬 Code graph analysis (3)
tests/model_registry/model_registry/upgrade/test_model_registry_upgrade.py (1)
tests/conftest.py (1)
  • admin_client (79-80)
tests/model_registry/scc/utils.py (1)
tests/conftest.py (1)
  • admin_client (79-80)
tests/model_registry/conftest.py (2)
tests/conftest.py (3)
  • admin_client (79-80)
  • is_byoidc (393-397)
  • original_user (819-822)
utilities/resources/model_registry_modelregistry_opendatahub_io.py (1)
  • ModelRegistry (9-94)
🪛 Ruff (0.14.10)
tests/model_registry/conftest.py

205-205: Unused function argument: original_user

(ARG001)

🔇 Additional comments (6)
tests/model_registry/model_registry/upgrade/test_model_registry_upgrade.py (1)

112-112: LGTM!

The addition of client=admin_client to the CustomResourceDefinition instantiation is consistent with the PR objective and correctly uses the provided admin_client parameter.

tests/model_registry/scc/utils.py (1)

93-93: LGTM!

The addition of client=admin_client to the Deployment instantiation is consistent with the PR objective and correctly uses the provided admin_client parameter.

tests/model_registry/conftest.py (4)

220-228: LGTM!

The addition of client=admin_client to the Secret instantiation is consistent with the PR objective.


242-242: LGTM!

The addition of client=admin_client to the OAuth instantiation is consistent with the PR objective.


297-299: LGTM!

The addition of client=admin_client to the ModelRegistry instantiation in the post-upgrade path is consistent with the PR objective.


340-368: LGTM!

The addition of client=admin_client to all resource instantiations (Secret, PersistentVolumeClaim, Service, ConfigMap, Deployment) in the post-upgrade path is consistent with the PR objective and correctly structured.

Comment thread tests/model_registry/conftest.py
Copy link
Copy Markdown
Contributor

@fege fege left a comment

Choose a reason for hiding this comment

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

/lgtm

Copy link
Copy Markdown
Contributor

@sheltoncyril sheltoncyril left a comment

Choose a reason for hiding this comment

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

/lgtm

@dbasunag dbasunag merged commit e8b1ede into opendatahub-io:main Jan 7, 2026
12 checks passed
@dbasunag dbasunag deleted the update_client_part1 branch January 7, 2026 15:31
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 7, 2026

Status of building tag latest: success.
Status of pushing tag latest to image registry: success.

mwaykole pushed a commit to mwaykole/opendatahub-tests that referenced this pull request Jan 23, 2026
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.

4 participants