Skip to content

inspectalerts: improve error message when no bearer token is available#2276

Open
danielmellado wants to merge 1 commit into
openshift:mainfrom
danielmellado:fix/inspect-alerts-improve-token-error-message
Open

inspectalerts: improve error message when no bearer token is available#2276
danielmellado wants to merge 1 commit into
openshift:mainfrom
danielmellado:fix/inspect-alerts-improve-token-error-message

Conversation

@danielmellado
Copy link
Copy Markdown

@danielmellado danielmellado commented May 25, 2026

When using certificate-based authentication (e.g. system:admin from installer kubeconfig), the monitoring API on Thanos Querier rejects the request because kube-rbac-proxy only supports TokenReview-based authentication on the web port (9091). The previous error message ("no token is currently in use for this session") did not explain why it failed or what the user should do.

Update the message to clarify that token-based auth is required and point users to 'oc login' or creating a service account with the 'cluster-monitoring-view' role.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error messaging for token-based authentication failures. When no token is detected, the message now clearly states token-based authentication is required for the monitoring API and directs users to authenticate (for example, by running oc login or using an appropriately scoped service account).

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 7cf0da23-918c-4c97-bcc9-44843e4b379d

📥 Commits

Reviewing files that changed from the base of the PR and between 1160753 and 6d280ec.

📒 Files selected for processing (1)
  • pkg/cli/admin/inspectalerts/inspectalerts.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/cli/admin/inspectalerts/inspectalerts.go

Walkthrough

ValidateRESTConfig's missing-token error text is updated to state that token-based authentication is required by the monitoring API and to hint that users should run oc login.

Changes

Authentication validation messaging

Layer / File(s) Summary
Token validation error message
pkg/cli/admin/inspectalerts/inspectalerts.go
ValidateRESTConfig error message is updated to require token-based authentication for the monitoring API and to suggest using oc login.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 12
✅ Passed checks (12 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main change: improving the error message when no bearer token is available in the inspectalerts command.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed PR contains only a non-test error message change in inspectalerts.go; no Ginkgo tests added or modified, making the test naming check inapplicable.
Test Structure And Quality ✅ Passed This PR does not contain any Ginkgo test code; it only modifies error messages in production code. The custom check for test quality is not applicable.
Microshift Test Compatibility ✅ Passed No Ginkgo e2e tests were added in this PR. The only change is to pkg/cli/admin/inspectalerts/inspectalerts.go, which is a CLI package containing only non-test code.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR modifies inspectalerts.go, a CLI utility package, not Ginkgo e2e tests. The SNO compatibility check applies only to new e2e tests, which are not present here.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only a CLI utility error message in inspectalerts.go; no deployment manifests, scheduling constraints, affinity rules, or topology assumptions are introduced.
Ote Binary Stdout Contract ✅ Passed File is a command package with no process-level code; error is written to stderr via kcmdutil.CheckErr, not stdout. Check is not applicable to this PR.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR contains no new Ginkgo e2e tests, only an error message improvement in a utility function. IPv6/disconnected compatibility check does not apply.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot requested review from rexagod and simonpasquier May 25, 2026 06:06
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 25, 2026
Comment thread pkg/cli/admin/inspectalerts/inspectalerts.go Outdated
When using certificate-based authentication (e.g. system:admin from
installer kubeconfig), the monitoring API on Thanos Querier rejects
the request because kube-rbac-proxy only supports TokenReview-based
authentication on the web port (9091). The previous error message
("no token is currently in use for this session") did not explain
why it failed or what the user should do.

Update the message to clarify that token-based auth is required and
point users to 'oc login'

Signed-off-by: Daniel Mellado <dmellado@fedoraproject.org>
@danielmellado danielmellado force-pushed the fix/inspect-alerts-improve-token-error-message branch from 1160753 to 6d280ec Compare May 27, 2026 08:49
Copy link
Copy Markdown

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 27, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 27, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danielmellado, simonpasquier

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@simonpasquier
Copy link
Copy Markdown

/verified by @simonpasquier

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label May 27, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@simonpasquier: This PR has been marked as verified by @simonpasquier.

Details

In response to this:

/verified by @simonpasquier

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.

@simonpasquier
Copy link
Copy Markdown

/test e2e-aws-ovn-upgrade

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 27, 2026

@danielmellado: 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

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants