[ACM-9339] Add cluster_mgmt API support for ROSA clusters (#1880)
- [ACM-9339] Add cluster_mgmt API support for ROSA clusters
Fixes ACM-8927 by querying the cluster_mgmt API to get the correct API server URL for ROSA clusters instead of relying on heuristics.
The heuristic approach (computing API URL from console URL) doesn’t work for ROSA HCP clusters, which have different URL patterns and use port 443 instead of 6443.
Changes:
- Created pkg/ocm/cluster package with client to query individual clusters by ID from cluster_mgmt API
- Updated discovery logic to query cluster_mgmt API for ROSA clusters (MOA, MOA-HostedControlPlane, ROSA, ROSA-HyperShift)
- Non-ROSA clusters continue to use the existing heuristic
- Graceful error handling: falls back to heuristic if cluster_mgmt API fails, ensuring discovery doesn’t break
- Added comprehensive unit tests with 97.1% coverage in pkg/ocm
This approach minimizes API calls (only for ROSA) and is resilient to API failures, avoiding the issues that caused PR #199 to be reverted.
Signed-off-by: Disaiah Bennett dbennett@redhat.com
Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com Signed-off-by: dislbenn dbennett@redhat.com
- Fix formatting issues from make fmt
Signed-off-by: dislbenn dbennett@redhat.com
- Add 30s timeout to HTTP client to prevent indefinite blocking
Addresses CodeRabbit feedback to add timeout to cluster API HTTP client.
Signed-off-by: dislbenn dbennett@redhat.com
- Fix empty BaseURL for cluster_mgmt API client
The cluster_mgmt API client was receiving an empty BaseURL because it directly used authRequest.BaseURL without defaulting it. Unlike the subscription client which sets its own default in NewClient(), the cluster client relied on the caller to provide the correct URL.
This fix adds a default OCM base URL constant and uses it when authRequest.BaseURL is empty, ensuring the cluster_mgmt API calls use https://api.openshift.com by default.
Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com Signed-off-by: dislbenn dbennett@redhat.com
- Remove verbose success log for cluster_mgmt API
Removed the DEBUG log that prints on every reconcile when successfully retrieving API URL from cluster_mgmt API. This was noisy during normal operation. Kept the failure/fallback logs which are useful for troubleshooting.
Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com Signed-off-by: dislbenn dbennett@redhat.com
Signed-off-by: dislbenn dbennett@redhat.com Co-authored-by: Claude Sonnet 4.5 noreply@anthropic.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802032778号
WORK IN PROGRESS
We are in the process of enabling this repo for community contribution. See wiki here.
Discovery
Operator for managing discovered clusters from OpenShift Cluster Manager
Prerequisites
Installation
Before deploying, the Discovery CRDs need to be installed onto the cluster.
Outside the Cluster
The operator can be run locally against the configured Kubernetes cluster in ~/.kube/config with the following command:
Inside the Cluster
The operator can also run inside the cluster as a Deployment. To do that first build the container image and push to an accessible image registry:
Usage
The discovery operator generates
DiscoveredClustersbased on aDiscoveryConfigresource. The config takes in a secret containing your OCM api token. To create this secret run the following:The OpenShift Cluster Manager API Token can be retrieved from here. This will create a secret named
ocm-api-tokenin the current namespace. With the secret created you can then create theDiscoveryConfigresource using the following commands:This will create a
DiscoveryConfiglike the example below:Rebuild Image: Wed Jan 8 12:52:04 EST 2025