目录
Disaiah Bennett

[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

1个月前383次提交

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

  • Go v1.25.0+
  • kubectl 1.21+
  • Operator-sdk v1.22.2
  • Docker
  • Connection to an existing Kubernetes cluster

Installation

Before deploying, the Discovery CRDs need to be installed onto the cluster.

make install

Outside the Cluster

The operator can be run locally against the configured Kubernetes cluster in ~/.kube/config with the following command:

make run

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:

  1. Build the image:
make docker-build URL=<registry>/<imagename>:<tag>
  1. Push the image:
make docker-push URL=<registry>/<imagename>:<tag>
  1. Deploy the Operator:
make deploy URL=<registry>/<imagename>:<tag>

Usage

The discovery operator generates DiscoveredClusters based on a DiscoveryConfig resource. The config takes in a secret containing your OCM api token. To create this secret run the following:

make secret OCM_API_TOKEN=<OpenShift Cluster Manager API Token>

The OpenShift Cluster Manager API Token can be retrieved from here. This will create a secret named ocm-api-token in the current namespace. With the secret created you can then create the DiscoveryConfig resource using the following commands:

make secret
make connfig

This will create a DiscoveryConfig like the example below:

apiVersion: discovery.open-cluster-management.io/v1
kind: DiscoveryConfig
metadata:
  name: discovery
spec:
  credential: ocm-api-token
  filters:
    lastActive: 7

Rebuild Image: Wed Jan 8 12:52:04 EST 2025

邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号