-
Notifications
You must be signed in to change notification settings - Fork 66
Test VM with MIG VGPU #4372
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
base: main
Are you sure you want to change the base?
Test VM with MIG VGPU #4372
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ | |
| from ocp_resources.datavolume import DataVolume | ||
| from ocp_resources.kubevirt import KubeVirt | ||
| from ocp_resources.node import Node | ||
| from ocp_resources.resource import ResourceEditor | ||
| from ocp_resources.resource import Resource, ResourceEditor | ||
| from ocp_resources.storage_profile import StorageProfile | ||
| from ocp_resources.virtual_machine import VirtualMachine | ||
| from ocp_resources.virtual_machine_instance_migration import VirtualMachineInstanceMigration | ||
|
|
@@ -689,3 +689,16 @@ def verify_rwx_default_storage(client: DynamicClient) -> None: | |
| f"Default storage class '{storage_class}' doesn't support RWX mode " | ||
| f"(required: RWX, found: {found_mode or 'none'})" | ||
| ) | ||
|
|
||
|
|
||
| def get_resource_by_name( | ||
| resource_kind: Resource, name: str, admin_client: DynamicClient, namespace: str | None = None | ||
| ) -> Resource: | ||
| kwargs = {"name": name} | ||
| if namespace: | ||
| kwargs["namespace"] = namespace | ||
| kwargs["client"] = admin_client | ||
| resource = resource_kind(**kwargs) | ||
| if resource.exists: | ||
| return resource | ||
| raise ResourceNotFoundError(f"{resource_kind} {name} not found.") | ||
|
Comment on lines
+694
to
+704
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MEDIUM: Add a Google-style docstring for this new shared helper. This is a public helper with non-obvious side effects (cluster lookup + Proposed fix def get_resource_by_name(
resource_kind: type[Resource], name: str, admin_client: DynamicClient, namespace: str | None = None
) -> Resource:
+ """Return an existing cluster resource by kind and name.
+
+ Args:
+ resource_kind (type[Resource]): Resource class to instantiate.
+ name (str): Resource name.
+ admin_client (DynamicClient): Cluster client.
+ namespace (str | None): Namespace for namespaced resources.
+
+ Returns:
+ Resource: The existing resource object.
+
+ Raises:
+ ResourceNotFoundError: If the resource does not exist.
+ """
kwargs = {"name": name}As per coding guidelines "Google-format docstrings REQUIRED for all public functions with non-obvious return values OR side effects". 🧰 Tools🪛 Ruff (0.15.9)[warning] 704-704: Avoid specifying long messages outside the exception class (TRY003) 🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: RedHatQE/openshift-virtualization-tests
Length of output: 675
🏁 Script executed:
Repository: RedHatQE/openshift-virtualization-tests
Length of output: 500
🏁 Script executed:
Repository: RedHatQE/openshift-virtualization-tests
Length of output: 294
🏁 Script executed:
Repository: RedHatQE/openshift-virtualization-tests
Length of output: 65
Fix type annotation and add required docstring for new helper.
The
resource_kindparameter is called as a constructor at line 701 (resource_kind(**kwargs)), so it must be typed astype[Resource], notResource. Current annotation breaks strict type checking and masks call-site errors.Additionally, this public helper performs cluster API interactions and raises exceptions—it requires a Google-format docstring explaining the behavior and exception handling per coding guidelines.
Proposed fixes
🤖 Prompt for AI Agents