-
Notifications
You must be signed in to change notification settings - Fork 133
OSD-28241: Add multi-environment OCM and backplane connection support #828
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: master
Are you sure you want to change the base?
Conversation
|
@nephomaniac: This pull request references OSD-28241 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.22.0" version, but no target version was set. DetailsIn response to this:
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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: nephomaniac The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@nephomaniac: This pull request references OSD-28241 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.22.0" version, but no target version was set. DetailsIn response to this:
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. |
|
/hold |
|
/label tide/merge-method-squash |
iamkirkbater
left a comment
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.
Smol change on whether or not this command should be present within the shipped binary (versus having this separate as an integration test artifact).
cmd/hive/loginhivetests.go
Outdated
| @@ -0,0 +1,518 @@ | |||
| package hive | |||
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.
Does this need to be an actual command? This feels more like an integration test to me, and shouldn't be in the "public API" of the CLI itself.
I'm not sure what the work required to "refactor" this out to be just an external test to be called elsewhere would be - but if I'm understanding the purpose of this command I'd argue that we should keep this separate from the cmd directory and run this as its own separate binary or something as an integration test.
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.
To clarify a bit - I love that this exists as an artifact that "proves" that the other libraries all work - I just think it doesn't need to be an actual osdctl command. We could either package this as a separate binary in like, /hack or something, or at a minimum we could make this a "hidden" command via https://pkg.go.dev/github.com/spf13/cobra#section-readme:~:text=of%20available%20commands.-,Hidden%20bool,-//%20SilenceErrors%20is%20an
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.
Thanks for the comments @iamkirkbater!
Correct, this is just an integration/manual test+example usage to help others with this PR/review. It doesn't necessarily even need to be in a build path or this PR/repo, but I also wasn't sure where things like should live(?). Easy to (re)move/refactor it out.
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.
I've removed this test command, and updated the summary with info on where to find, build and run this test or other integration tests:
"This test has been moved to https://github.com/nephomaniac/osdctl/tree/integration-tests with information on how to build and run the tests in the osdctl/test/ directory"
This can be a follow up PR if an integration test directory/structure is desired.
Thanks!
|
@nephomaniac: This pull request references OSD-28241 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.22.0" version, but no target version was set. DetailsIn response to this:
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: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. |
OSD-28241: Add multi-environment OCM and backplane connection support
Summary
This PR makes use of recent backplane-cli changes allowing OCM connections to be passed and persisted to the backplane functions. This PR adds support for managing OCM and backplane connections to clusters across different OCM environments (production, staging, integration). This enables workflows where target clusters and their hive clusters exist in different OCM environments.
Problem Statement
Currently, osdctl assumes that target clusters and their corresponding hive clusters exist in the same OCM environment. This limitation prevents SREs from managing clusters that span multiple OCM environments, such as:
Solution
This PR introduces new utility functions and client helpers that accept OCM SDK connections as parameters, allowing explicit control over which OCM environment is used for each operation.
Key Features
1. Multi-Environment OCM Connections
production,staging,integration2. Cross-Environment Hive Access
GetHiveBPClientForCluster()- Connect to hive clusters in different OCM environmentsGetHiveClusterWithConn()- Fetch hive cluster metadata using custom connections3. Connection-Based Client Helpers
NewWithConn()/NewAsBackplaneClusterAdminWithConn()- Create k8s clients with custom OCM connectionsGetKubeConfigAndClientWithConn()- Get kubeconfig and clientset with custom connectionsChanges
New Functions
pkg/utils/ocm.go (+285 lines)
GetHiveBPClientForCluster()- Create backplane client for hive cluster with optional OCM URLGetHiveClusterWithConn()- Fetch hive cluster using separate target and hive OCM connectionsGetHiveShardWithConn()- Get hive shard URL with custom OCM connectionCreateConnectionWithUrl()- Create OCM connection with URL or alias (production/staging/integration)GetOCMConfigFromEnv()- Load OCM configuration from environment variablesGetOcmConfigFromFilePath()- Load OCM configuration from JSON fileGetOCMSdkConnBuilderFromConfig()- Build OCM connection from config objectGetOCMSdkConnBuilderFromFilePath()- Build OCM connection from config fileGetOCMSdkConnFromFilePath()- Create OCM connection directly from filepkg/k8s/client.go (+41 lines)
NewWithConn()- Create Kubernetes client with provided OCM connectionNewAsBackplaneClusterAdminWithConn()- Create elevated Kubernetes client with provided OCM connectioncmd/common/helpers.go (+29 lines)
GetKubeConfigAndClientWithConn()- Get kubeconfig and clients using provided OCM connectioncmd/hive/loginhivetests.go (NEW, 519 lines)
New Test Files
cmd/common/helpers_test.go (+70 lines)
GetKubeConfigAndClientWithConn()pkg/k8s/client_test.go (+117 lines)
NewWithConn()andNewAsBackplaneClusterAdminWithConn()pkg/utils/ocm_test.go (+602 lines)
Testing
Test Coverage
Manual Testing
(Update: this test has been moved to https://github.com/nephomaniac/osdctl/tree/integration-tests with information on how to build and run the tests in the osdctl/test/ dir)
The new
osdctl hive login-testscommand provides real-world validation:Usage Examples
Example 1: Access hive cluster in production when target is in staging
Example 2: Use custom OCM connections
Example 3: Integration test command
Backward Compatibility
✅ All existing functions remain unchanged