Skip to content

SREP-3940: Add --hive-ocm-url flag to cluster break-glass for multi-env OCM support#864

Open
nephomaniac wants to merge 1 commit intoopenshift:masterfrom
nephomaniac:SREP-3940-break-glass-multi-env-ocm
Open

SREP-3940: Add --hive-ocm-url flag to cluster break-glass for multi-env OCM support#864
nephomaniac wants to merge 1 commit intoopenshift:masterfrom
nephomaniac:SREP-3940-break-glass-multi-env-ocm

Conversation

@nephomaniac
Copy link
Contributor

@nephomaniac nephomaniac commented Mar 13, 2026

Summary

Adds --hive-ocm-url flag to osdctl cluster break-glass command to enable multi-environment OCM support for staging/integration testing.

Changes

  • Added --hive-ocm-url optional flag to break-glass command
  • Implements conditional logic to use separate OCM connections for target cluster and hive when flag is provided
  • Added early validation in accessCmdComplete() to fail fast on invalid OCM URLs
  • Preserves backward compatibility - original code path unchanged when flag not provided
  • Supports OCM URL aliases: 'production', 'staging', 'integration'
  • Updated unit tests in access_test.go to verify early validation behavior

Implementation Details

When --hive-ocm-url is specified:

  1. Creates separate OCM connection for hive using utils.CreateConnectionWithUrl()
  2. Uses utils.GetHiveClusterWithConn() to query hive from different OCM environment
  3. Creates hive k8s client with k8s.NewAsBackplaneClusterAdminWithConn()
  4. Validates OCM URL early using utils.ValidateAndResolveOcmUrl()

Testing

  • ✅ Tested in staging environment with valid --hive-ocm-url values
  • ✅ Tested in production environment with valid --hive-ocm-url values
  • ✅ Validated early failure with invalid --hive-ocm-url values
  • ✅ Backward compatibility verified (command works without --hive-ocm-url flag)
  • ✅ Unit tests passing (including new tests for validation logic)

Related

Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com

@openshift-ci-robot
Copy link

@nephomaniac: An error was encountered searching for bug SREP-3940 on the Jira server at https://issues.redhat.com. No known errors were detected, please see the full error message for details.

Full error message. No response returned: Get "https://issues.redhat.com/rest/api/2/issue/SREP-3940": GET https://issues.redhat.com/rest/api/2/issue/SREP-3940 giving up after 5 attempt(s)

Please contact an administrator to resolve this issue, then request a bug refresh with /jira refresh.

Details

In response to this:

Summary

Adds --hive-ocm-url flag to osdctl cluster break-glass command to enable multi-environment OCM support for staging/integration testing.

Changes

  • Added --hive-ocm-url optional flag to break-glass command
  • Implements conditional logic to use separate OCM connections for target cluster and hive when flag is provided
  • Added early validation in accessCmdComplete() to fail fast on invalid OCM URLs
  • Preserves backward compatibility - original code path unchanged when flag not provided
  • Supports OCM URL aliases: 'production', 'staging', 'integration'

Implementation Details

When --hive-ocm-url is specified:

  1. Creates separate OCM connection for hive using utils.CreateConnectionWithUrl()
  2. Uses utils.GetHiveClusterWithConn() to query hive from different OCM environment
  3. Creates hive k8s client with k8s.NewAsBackplaneClusterAdminWithConn()
  4. Validates OCM URL early using utils.ValidateAndResolveOcmUrl()

Testing

  • ✅ Tested in staging environment with valid --hive-ocm-url values
  • ✅ Tested in production environment with valid --hive-ocm-url values
  • ✅ Validated early failure with invalid --hive-ocm-url values
  • ✅ Backward compatibility verified (command works without --hive-ocm-url flag)

Related

Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com

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.

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

Warning

Rate limit exceeded

@nephomaniac has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 1 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6a83b868-cd78-42ba-99de-d73475d91f9f

📥 Commits

Reviewing files that changed from the base of the PR and between f413494 and b520a7d.

📒 Files selected for processing (4)
  • cmd/cluster/access/access.go
  • cmd/cluster/access/access_test.go
  • docs/README.md
  • docs/osdctl_cluster_break-glass.md

Walkthrough

Adds a --hive-ocm-url command flag and hiveOcmUrl field, validates the value, and extends command Run logic to optionally create a separate OCM connection for hive operations while preserving the original single-OCM path when the flag is unset.

Changes

Cohort / File(s) Summary
Access command implementation
cmd/cluster/access/access.go
Adds --hive-ocm-url flag and hiveOcmUrl field; validates provided URL; updates Run to support a multi-environment path that builds a separate OCM connection and uses NewAsBackPlaneClusterAdminWithConn; preserves fallback to original behavior when empty; adds related logging and error messaging.
CLI docs: README
docs/README.md
Documents new --hive-ocm-url flag and its alias note; brief single-line addition to CLI docs.
CLI docs: command reference
docs/osdctl_cluster_break-glass.md
Adds --hive-ocm-url option to command reference with description and alignment changes; updates example/flags list accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@openshift-ci openshift-ci bot requested review from MateSaary and joshbranham March 13, 2026 22:59
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 13, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nephomaniac
Once this PR has been reviewed and has the lgtm label, please assign nikokolas3270 for approval. For more information see the Code Review Process.

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

@nephomaniac
Copy link
Contributor Author

Placing on hold until all the similar commands/PRs adding multiple OCM env support can have the common impl pattern reviewed. Will unhold after the other PRs, and general pattern get a chance for review.
/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 13, 2026
@nephomaniac nephomaniac force-pushed the SREP-3940-break-glass-multi-env-ocm branch from 4e00788 to f413494 Compare March 13, 2026 23:17
Copy link

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmd/cluster/access/access.go`:
- Around line 174-177: The hive lookup is using the user-provided c.clusterID
which can be a name/external ID; change the call to osdctlutil.GetHiveCluster to
use the already-resolved internal ID from cluster.ID() instead of c.clusterID
(ensure the local variable named cluster is in scope and pass cluster.ID() into
GetHiveCluster so hive interactions use the internal cluster ID as intended).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b3b2b5ae-0c6f-4bdd-99dc-7f9c0f53024b

📥 Commits

Reviewing files that changed from the base of the PR and between 4e00788 and f413494.

📒 Files selected for processing (3)
  • cmd/cluster/access/access.go
  • docs/README.md
  • docs/osdctl_cluster_break-glass.md

Comment on lines +174 to +177
hive, err = osdctlutil.GetHiveCluster(c.clusterID)
if err != nil {
return fmt.Errorf("failed to retrieve hive shard for %q: %w", c.clusterID, err)
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Use internal cluster ID for default hive lookup to avoid lookup failures.

At Line 174, the default path uses c.clusterID (user input), while the flow already resolved cluster.ID() and the comment at Lines 138-139 states hive interactions should use internal ID. This can fail for name/external-ID inputs and breaks backward-compat expectations.

🔧 Proposed fix
-		hive, err = osdctlutil.GetHiveCluster(c.clusterID)
+		hive, err = osdctlutil.GetHiveCluster(cluster.ID())
 		if err != nil {
 			return fmt.Errorf("failed to retrieve hive shard for %q: %w", c.clusterID, err)
 		}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/cluster/access/access.go` around lines 174 - 177, The hive lookup is
using the user-provided c.clusterID which can be a name/external ID; change the
call to osdctlutil.GetHiveCluster to use the already-resolved internal ID from
cluster.ID() instead of c.clusterID (ensure the local variable named cluster is
in scope and pass cluster.ID() into GetHiveCluster so hive interactions use the
internal cluster ID as intended).

@nephomaniac nephomaniac force-pushed the SREP-3940-break-glass-multi-env-ocm branch from f413494 to b978c75 Compare March 13, 2026 23:52
@openshift-ci-robot
Copy link

@nephomaniac: An error was encountered searching for bug SREP-3940 on the Jira server at https://issues.redhat.com. No known errors were detected, please see the full error message for details.

Full error message. No response returned: Get "https://issues.redhat.com/rest/api/2/issue/SREP-3940": GET https://issues.redhat.com/rest/api/2/issue/SREP-3940 giving up after 5 attempt(s)

Please contact an administrator to resolve this issue, then request a bug refresh with /jira refresh.

Details

In response to this:

Summary

Adds --hive-ocm-url flag to osdctl cluster break-glass command to enable multi-environment OCM support for staging/integration testing.

Changes

  • Added --hive-ocm-url optional flag to break-glass command
  • Implements conditional logic to use separate OCM connections for target cluster and hive when flag is provided
  • Added early validation in accessCmdComplete() to fail fast on invalid OCM URLs
  • Preserves backward compatibility - original code path unchanged when flag not provided
  • Supports OCM URL aliases: 'production', 'staging', 'integration'
  • Updated unit tests in access_test.go to verify early validation behavior

Implementation Details

When --hive-ocm-url is specified:

  1. Creates separate OCM connection for hive using utils.CreateConnectionWithUrl()
  2. Uses utils.GetHiveClusterWithConn() to query hive from different OCM environment
  3. Creates hive k8s client with k8s.NewAsBackplaneClusterAdminWithConn()
  4. Validates OCM URL early using utils.ValidateAndResolveOcmUrl()

Testing

  • ✅ Tested in staging environment with valid --hive-ocm-url values
  • ✅ Tested in production environment with valid --hive-ocm-url values
  • ✅ Validated early failure with invalid --hive-ocm-url values
  • ✅ Backward compatibility verified (command works without --hive-ocm-url flag)
  • ✅ Unit tests passing (including new tests for validation logic)

Related

Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com

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.

@nephomaniac nephomaniac force-pushed the SREP-3940-break-glass-multi-env-ocm branch from b978c75 to b520a7d Compare March 14, 2026 00:05
@nephomaniac
Copy link
Contributor Author

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 14, 2026

@nephomaniac: all tests passed!

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants