openshift / openshift/osdctl

osdctl rhobs logs: incorrect Grafana URL for HCP clusters

Open
#932 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
47
Forks
142
Avg merge
21h 19m
Merged PRs (30d)
9

Description

Summary

osdctl rhobs logs -C <hcp-cluster-id> --url generates an incorrect Grafana URL for HCP (Hosted Control Plane) clusters. The URL shows no logs when opened in a browser.

Root Cause

When given an HCP cluster ID, the command:

  1. Correctly resolves the RHOBS cell by looking up the management cluster (MC)
  2. But incorrectly uses the HCP cluster's openshift_cluster_id (external UUID) as the Loki filter

HCP control-plane logs run in a namespace on the MC (e.g. ocm-production-<hcp-id>-...) and are indexed in RHOBS under the MC's openshift_cluster_id, not the HCP cluster's.

The generated query is:

{k8s_namespace_name="default"} | openshift_cluster_id = "<hcp-external-uuid>"

This returns no logs because:

  • k8s_namespace_name="default" is not where HCP control-plane logs live
  • openshift_cluster_id = "<hcp-external-uuid>" is the wrong cluster label for RHOBS HCP logs

Expected Behavior

For an HCP cluster, the URL should use:

  • Namespace: the HCP control-plane namespace on the MC, e.g. ocm-production-<hcp-id>-<suffix> (available via GetHCPNamespace)
  • openshift_cluster_id: the MC's external UUID (available via GetManagementCluster(...).ExternalID())

Working Loki query (confirmed by user investigation):

{k8s_namespace_name="ocm-production-<hcp-id>-<suffix>"} | openshift_cluster_id = "<mc-external-uuid>"

Steps to Reproduce

osdctl rhobs logs -C <hcp-cluster-id> --url

Open the generated URL — shows "No logs found".

Compare with:

osdctl rhobs logs -C <mc-cluster-id> --url

Then manually set the namespace to the HCP namespace — shows logs correctly.

Affected Code

cmd/rhobs/logs_cmd.go — the GetDefaultGrafanaLogsUrl() method and the namespace flag default value ("default").

When populateRhobsFetchers is called with an HCP cluster ID, it sets monitoredClusterId to the MC's internal ID (correct for RHOBS cell resolution) but leaves clusterExternalId as the HCP cluster's external UUID (wrong for the Loki query).

Fix

In populateRhobsFetchers (or in the logs URL generation path), when the cluster is an HCP cluster:

  1. Fetch the HCP namespace via utils.GetHCPNamespace(clusterId)
  2. Fetch the MC's external UUID via utils.GetManagementCluster(clusterId).ExternalID()
  3. Use these to build the correct Loki stream selector and filter

Note: osdctl cluster context has already been patched with this workaround separately.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in cmd/rhobs/logs_cmd.go by reading populateRhobsFetchers and GetDefaultGrafanaLogsUrl, then reproduce the issue with osdctl rhobs logs -C --url. Verify the generated URL uses the HCP namespace from GetHCPNamespace and the management cluster's ExternalID; done means opening it shows HCP control-plane logs.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.