Skip to content

MGMT-21040: Hide the infraenv concept better#19

Merged
carbonin merged 2 commits intoopenshift-assisted:masterfrom
carbonin:hide-infraenv
Jul 10, 2025
Merged

MGMT-21040: Hide the infraenv concept better#19
carbonin merged 2 commits intoopenshift-assisted:masterfrom
carbonin:hide-infraenv

Conversation

@carbonin
Copy link
Copy Markdown
Collaborator

@carbonin carbonin commented Jul 8, 2025

The information in the infraenv is generally not of much use to the
user. This is why the entire concept is hidden from them in the SaaS UI.
In order to be able to support getting the download URL for clusters
created outside of the current session and to further hide the infraenv
concept this PR changes the infraenv_info tool into
cluster_iso_download_url which takes just a cluster ID as input.

While a cluster can have multiple infraenvs, this is currently not an
expected flow in the SaaS so we simply return all that we find without
additional context. In the future if this MCP server is required to
support multi-arch deployments (the most common use-case for multiple
infraenvs) then maybe more information will need to accompany the
multiple URLs.

Screenshot From 2025-07-08 15-15-57

https://issues.redhat.com/browse/MGMT-21040

Summary by CodeRabbit

  • Documentation

    • Updated documentation to reflect the renaming and revised behavior of the ISO download URL tool, now associated with clusters instead of infra environments.
  • New Features

    • Introduced a tool to retrieve ISO download URLs for a cluster, supporting multiple URLs if available.
  • Bug Fixes

    • Improved error handling for cluster creation and ISO URL retrieval when expected data is missing.
  • Tests

    • Added and updated tests to cover the new cluster ISO download URL functionality, including handling of multiple URLs and error scenarios.

carbonin added 2 commits July 8, 2025 14:56
The information in the infraenv is generally not of much use to the
user. This is why the entire concept is hidden from them in the SaaS UI.
In order to be able to support getting the download URL for clusters
created outside of the current session and to further hide the infraenv
concept this commit changes the infraenv_info tool into
cluster_iso_download_url which takes just a cluster ID as input.

While a cluster can have multiple infraenvs, this is currently not an
expected flow in the SaaS so we simply return all that we find without
additional context. In the future if this MCP server is required to
support multi-arch deployments (the most common use-case for multiple
infraenvs) then maybe more information will need to accompany the
multiple URLs.

https://issues.redhat.com/browse/MGMT-21040
@carbonin carbonin requested a review from eranco74 July 8, 2025 19:19
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 8, 2025
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Jul 8, 2025

@carbonin: This pull request references MGMT-21040 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.20.0" version, but no target version was set.

Details

In response to this:

The information in the infraenv is generally not of much use to the
user. This is why the entire concept is hidden from them in the SaaS UI.
In order to be able to support getting the download URL for clusters
created outside of the current session and to further hide the infraenv
concept this PR changes the infraenv_info tool into
cluster_iso_download_url which takes just a cluster ID as input.

While a cluster can have multiple infraenvs, this is currently not an
expected flow in the SaaS so we simply return all that we find without
additional context. In the future if this MCP server is required to
support multi-arch deployments (the most common use-case for multiple
infraenvs) then maybe more information will need to accompany the
multiple URLs.

Screenshot From 2025-07-08 15-15-57

https://issues.redhat.com/browse/MGMT-21040

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Jul 8, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: carbonin

The full list of commands accepted by this bot can be found here.

Details 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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 8, 2025

Walkthrough

The codebase replaces the infraenv_info tool with a new cluster_iso_download_url tool, shifting from retrieving detailed infra environment information by infraenv ID to fetching ISO download URLs by cluster ID. Supporting API client methods and tests are updated or added to reflect this new functionality, including error handling and test coverage.

Changes

File(s) Change Summary
README.md Updated documentation: replaced infraenv_info tool section with cluster_iso_download_url; updated tool signature and description.
server.py Replaced infraenv_info function with cluster_iso_download_url; updated create_cluster to change return type and add error handling.
service_client/assisted_service_api.py Added list_infra_envs async method to InventoryClient for retrieving infraenvs by cluster ID with error handling.
tests/test_assisted_service_api.py Added async tests for list_infra_envs covering success and API exception scenarios.
tests/test_server.py Replaced and expanded tests: updated for cluster_iso_download_url, added tests for multiple/no infraenvs, simplified cluster creation test.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Server
    participant InventoryClient
    participant AssistedServiceAPI

    User->>Server: cluster_iso_download_url(cluster_id)
    Server->>InventoryClient: list_infra_envs(cluster_id)
    InventoryClient->>AssistedServiceAPI: list_infra_envs(cluster_id)
    AssistedServiceAPI-->>InventoryClient: List of infraenvs
    InventoryClient-->>Server: List of infraenvs
    Server-->>User: ISO download URLs (newline-separated)
Loading

Suggested labels

size/L, lgtm

Poem

A cluster asked, “Where’s my ISO treat?”
The server replied, “Let’s not miss a beat!”
Out with the old, in with the new,
Download URLs, just for you.
With tests that hop and docs that gleam,
The code now runs like a rabbit’s dream! 🐇✨

✨ 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@openshift-ci openshift-ci Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 8, 2025
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Jul 8, 2025

@carbonin: This pull request references MGMT-21040 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.20.0" version, but no target version was set.

Details

In response to this:

The information in the infraenv is generally not of much use to the
user. This is why the entire concept is hidden from them in the SaaS UI.
In order to be able to support getting the download URL for clusters
created outside of the current session and to further hide the infraenv
concept this PR changes the infraenv_info tool into
cluster_iso_download_url which takes just a cluster ID as input.

While a cluster can have multiple infraenvs, this is currently not an
expected flow in the SaaS so we simply return all that we find without
additional context. In the future if this MCP server is required to
support multi-arch deployments (the most common use-case for multiple
infraenvs) then maybe more information will need to accompany the
multiple URLs.

Screenshot From 2025-07-08 15-15-57

https://issues.redhat.com/browse/MGMT-21040

Summary by CodeRabbit

  • Documentation

  • Updated documentation to reflect the renaming and revised behavior of the ISO download URL tool, now associated with clusters instead of infra environments.

  • New Features

  • Introduced a tool to retrieve ISO download URLs for a cluster, supporting multiple URLs if available.

  • Bug Fixes

  • Improved error handling for cluster creation and ISO URL retrieval when expected data is missing.

  • Tests

  • Added and updated tests to cover the new cluster ISO download URL functionality, including handling of multiple URLs and error scenarios.

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 openshift-eng/jira-lifecycle-plugin repository.

Copy link
Copy Markdown

@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)
README.md (1)

109-112: Fix spacing and formatting issues.

The documentation changes correctly reflect the new tool functionality, but there are some formatting issues that should be addressed.

Apply these formatting fixes:

-### ISO Download URL
+### ISO Download URL

-* **cluster_iso_download_url** - Get ISO download URL(s) for a cluster. Returns ISO download URLs separated by newlines if multiple exist.
+* **cluster_iso_download_url** — Get ISO download URL(s) for a cluster. Returns ISO download URLs separated by newlines if multiple exist.
-  * `cluster_id`: Cluster ID (string, required)
+  * `cluster_id`: Cluster ID (string, required)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1dcd9f1 and 1421aff.

📒 Files selected for processing (5)
  • README.md (1 hunks)
  • server.py (4 hunks)
  • service_client/assisted_service_api.py (1 hunks)
  • tests/test_assisted_service_api.py (1 hunks)
  • tests/test_server.py (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
tests/test_assisted_service_api.py (1)
service_client/assisted_service_api.py (1)
  • list_infra_envs (256-291)
server.py (2)
tests/test_assisted_service_api.py (1)
  • client (25-30)
service_client/assisted_service_api.py (3)
  • InventoryClient (22-623)
  • list_infra_envs (256-291)
  • create_cluster (293-342)
tests/test_server.py (2)
service_client/assisted_service_api.py (1)
  • list_infra_envs (256-291)
server.py (1)
  • cluster_iso_download_url (203-249)
🪛 LanguageTool
README.md

[grammar] ~109-~109: Use proper spacing conventions.
Context: ...(string, required) ### ISO Download URL * cluster_iso_download_url - Get ISO dow...

(QB_NEW_EN_OTHER_ERROR_IDS_000007)


[typographical] ~111-~111: To join two clauses or set off examples, consider using an em dash.
Context: ...g, required) ### ISO Download URL * cluster_iso_download_url - Get ISO download URL(s) for a cluster. Retu...

(QB_NEW_EN_DASH_RULE_EM)


[grammar] ~111-~111: There might be a problem here.
Context: ...separated by newlines if multiple exist. * cluster_id: Cluster ID (string, required) ### Host...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~112-~112: Use proper spacing conventions.
Context: ...uster_id`: Cluster ID (string, required) ### Host Management * set_host_role - U...

(QB_NEW_EN_OTHER_ERROR_IDS_000007)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Red Hat Konflux / assisted-service-mcp-saas-main-on-pull-request
🔇 Additional comments (6)
service_client/assisted_service_api.py (1)

256-292: LGTM! Well-implemented API method.

The list_infra_envs method follows the established patterns in the codebase with proper:

  • Async implementation using asyncio.to_thread
  • Comprehensive error handling for both ApiException and generic exceptions
  • Detailed logging for debugging
  • Correct type hints
tests/test_assisted_service_api.py (1)

296-334: Comprehensive test coverage for the new API method.

The tests properly cover both success and error scenarios:

  • Success case validates correct API call and return value
  • Exception handling test ensures proper error propagation
  • Mocking strategy is consistent with other tests in the file
server.py (2)

203-249: Well-implemented function that properly handles multiple infra envs.

The cluster_iso_download_url function correctly:

  • Uses the new list_infra_envs API method
  • Handles edge cases (no infra envs, no download URLs)
  • Extracts URLs from each infra env and joins with newlines
  • Provides user-friendly error messages
  • Includes comprehensive logging

286-300: Good error handling and simplified return value.

The changes to create_cluster are consistent with hiding the infraenv concept:

  • Returns only the cluster ID instead of JSON with both cluster and infraenv IDs
  • Adds proper error handling for when cluster.id is None
  • Still creates the infraenv but doesn't expose its ID to users
tests/test_server.py (2)

342-428: Comprehensive test coverage for all scenarios.

The updated tests properly cover:

  • Single infra env scenario with correct URL extraction
  • Multiple infra envs with newline-separated URLs
  • No infra envs scenario with appropriate error message
  • Proper mocking of the new list_infra_envs method

456-456: Correct assertion for simplified return value.

The test correctly expects just the cluster ID string instead of JSON, consistent with the updated create_cluster function behavior.

@carbonin carbonin merged commit 633009d into openshift-assisted:master Jul 10, 2025
12 checks passed
@carbonin carbonin deleted the hide-infraenv branch July 10, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants