Skip to content

Ensure Platform Prometheus targets are not scraped with insecure_skip_verify#31373

Open
machine424 wants to merge 1 commit into
openshift:mainfrom
machine424:skipCAA
Open

Ensure Platform Prometheus targets are not scraped with insecure_skip_verify#31373
machine424 wants to merge 1 commit into
openshift:mainfrom
machine424:skipCAA

Conversation

@machine424

@machine424 machine424 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Tests
    • Added coverage to ensure Prometheus scrape settings do not disable TLS certificate verification.
    • The new check retrieves the current scrape configuration, inspects embedded TLS settings, and fails if any scrape job is configured to skip TLS CA verification—except for explicitly allowed job names.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 9, 2026
@machine424

Copy link
Copy Markdown
Contributor Author

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 88f07cf1-eb5e-4127-9d26-ff57643b416b

📥 Commits

Reviewing files that changed from the base of the PR and between 5115c57 and e49f0f7.

📒 Files selected for processing (1)
  • test/extended/prometheus/prometheus.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/extended/prometheus/prometheus.go

Walkthrough

Adds a Ginkgo test that retrieves Prometheus scrape configuration, parses the embedded YAML, and fails when non-allowlisted scrape jobs set insecure_skip_verify to true.

Changes

Prometheus TLS Verification Test

Layer / File(s) Summary
Validate scrape configuration TLS settings
test/extended/prometheus/prometheus.go
Fetches /api/v1/status/config with existing authentication, validates the number of scrape configs, and checks that TLS verification is not disabled except for allowlisted jobs.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: slashpai

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Microshift Test Compatibility ⚠️ Warning The new It() has no MicroShift tag/guard and queries openshift-monitoring/prometheus-k8s via the Prometheus route, which MicroShift doesn’t support. Add a [Skipped:MicroShift] or suitable [apigroup:...] tag, or guard with exutil.IsMicroShiftCluster()+g.Skip() before touching openshift-monitoring/prometheus-k8s.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: validating that Prometheus scrape targets do not use insecure_skip_verify.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 The added Ginkgo title is static and deterministic: should not skip TLS CA verification; no dynamic pod, namespace, UUID, or timestamp data appears in test names.
Test Structure And Quality ✅ Passed New Ginkgo It is focused on one config invariant, has no resource lifecycle to clean up, uses helper timeouts, and matches local Prometheus test patterns.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The new test only fetches and parses Prometheus config; it has no node-count, scheduling, failover, or multi-node assumptions, so it should run on SNO.
Topology-Aware Scheduling Compatibility ✅ Passed Only adds a read-only Prometheus config validation test; no manifests, controllers, replicas, affinity, selectors, or scheduling constraints changed.
Ote Binary Stdout Contract ✅ Passed PASS: New test only uses It-block logging; the only stdout write is fmt.Printf in a regular helper, not main/init/suite setup.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed New test only queries the cluster Prometheus route via helpers and parses config; no IPv4 literals, host:port concatenation, or external internet use.
No-Weak-Crypto ✅ Passed Only a new test was added; it parses Prometheus config and checks a boolean flag. No MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret comparisons found.
Container-Privileges ✅ Passed Only a Go test file changed; no container/K8s manifests or securityContext settings were added or modified.
No-Sensitive-Data-In-Logs ✅ Passed New logging only prints Prometheus scrape job names and a boolean skip flag; no secrets, PII, tokens, or customer data are logged.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/extended/prometheus/prometheus.go (1)

146-169: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Brittle substring match on TLS error text.

strings.Contains(curlErrMsg, "certificate required") couples the etcd pass condition to the exact wording emitted by whatever TLS backend curl is built against. If the backend (OpenSSL vs. others) or curl version phrases the mTLS handshake alert differently, this branch silently falls through to the retry/timeout path. Consider matching a broader signal (e.g. statusCode == 0 && err != nil for the etcd/etcd job) or documenting the assumed curl/TLS backend.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/extended/prometheus/prometheus.go` around lines 146 - 169, The etcd mTLS
exception in the polling closure is too dependent on the exact curl error text,
so update the `wait.PollUntilContextTimeout` callback to avoid
`strings.Contains(curlErrMsg, "certificate required")` as the deciding signal.
In the `targetNs == "openshift-etcd"` and `targetJob == "etcd"` branch, prefer a
broader condition based on the existing `statusCode == 0` and `err != nil`
checks (or otherwise make the TLS assumption explicit in the test), so the
`scrapeErr` logic in this block remains stable across curl/TLS backend
differences.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/extended/prometheus/prometheus.go`:
- Around line 146-169: The etcd mTLS exception in the polling closure is too
dependent on the exact curl error text, so update the
`wait.PollUntilContextTimeout` callback to avoid `strings.Contains(curlErrMsg,
"certificate required")` as the deciding signal. In the `targetNs ==
"openshift-etcd"` and `targetJob == "etcd"` branch, prefer a broader condition
based on the existing `statusCode == 0` and `err != nil` checks (or otherwise
make the TLS assumption explicit in the test), so the `scrapeErr` logic in this
block remains stable across curl/TLS backend differences.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: b47b2f75-8acc-4c30-8669-d0dc97e770d5

📥 Commits

Reviewing files that changed from the base of the PR and between 965e8a0 and c9e60d5.

📒 Files selected for processing (2)
  • test/extended/prometheus/prometheus.go
  • test/extended/util/prometheus/helpers.go

@openshift-ci openshift-ci Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Jul 9, 2026
@machine424

Copy link
Copy Markdown
Contributor Author

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@openshift-trt

openshift-trt Bot commented Jul 9, 2026

Copy link
Copy Markdown

Risk analysis has seen new tests most likely introduced by this PR.
Please ensure that new tests meet guidelines for naming and stability.

New Test Risks for sha: 3e2b3ca

Job Name New Test Risk
pull-ci-openshift-origin-main-e2e-aws-ovn-fips High - "[sig-instrumentation][Late] Platform Prometheus targets should not skip TLS CA verification [Suite:openshift/conformance/parallel]" is a new test that failed 1 time(s) against the current commit
pull-ci-openshift-origin-main-e2e-aws-ovn-serial-1of2 High - "[sig-instrumentation][Late] Platform Prometheus targets should not skip TLS CA verification [Suite:openshift/conformance/parallel]" is a new test that failed 1 time(s) against the current commit
pull-ci-openshift-origin-main-e2e-aws-ovn-serial-2of2 High - "[sig-instrumentation][Late] Platform Prometheus targets should not skip TLS CA verification [Suite:openshift/conformance/parallel]" is a new test that failed 1 time(s) against the current commit
pull-ci-openshift-origin-main-e2e-gcp-ovn High - "[sig-instrumentation][Late] Platform Prometheus targets should not skip TLS CA verification [Suite:openshift/conformance/parallel]" is a new test that failed 1 time(s) against the current commit
pull-ci-openshift-origin-main-e2e-metal-ipi-ovn-ipv6 High - "[sig-instrumentation][Late] Platform Prometheus targets should not skip TLS CA verification [Suite:openshift/conformance/parallel]" is a new test that failed 1 time(s) against the current commit
pull-ci-openshift-origin-main-e2e-vsphere-ovn High - "[sig-instrumentation][Late] Platform Prometheus targets should not skip TLS CA verification [Suite:openshift/conformance/parallel]" is a new test that failed 1 time(s) against the current commit
pull-ci-openshift-origin-main-e2e-vsphere-ovn-upi High - "[sig-instrumentation][Late] Platform Prometheus targets should not skip TLS CA verification [Suite:openshift/conformance/parallel]" is a new test that failed 1 time(s) against the current commit

New tests seen in this PR at sha: 3e2b3ca

  • "[sig-instrumentation][Late] Platform Prometheus targets should not skip TLS CA verification [Suite:openshift/conformance/parallel]" [Total: 7, Pass: 0, Fail: 7, Flake: 0]

Comment thread test/extended/prometheus/prometheus.go
@machine424 machine424 changed the title WIP: Ensure Platform Prometheus targets are not scraped with insecure_skip_verify Ensure Platform Prometheus targets are not scraped with insecure_skip_verify Jul 16, 2026
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 16, 2026
Comment thread test/extended/prometheus/prometheus.go
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@danielmellado danielmellado left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, besides what I said about what happens to this when the bugs are fixed. If you intend to do a follow-up PR then it's just fine, thanks!

Comment on lines +217 to +222
g.It("should not skip TLS CA verification", func() {
// TODO: remove the job when the bug is fixed.
jobsToSkip := []string{
"serviceMonitor/openshift-apiserver/openshift-apiserver-operator-check-endpoints/0", // https://issues.redhat.com/browse/OCPBUGS-98917
"serviceMonitor/openshift-network-diagnostics/network-check-source/0", // https://issues.redhat.com/browse/OCPBUGS-98918
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Once the bugs are fixed, these entries become silent dead weight. Optional hardening: after the loop, assert each allowlisted job was observed with insecure_skip_verify: true, and fail if an exception is unused so the TODO list self-cleans. Same pattern as “exclude list should be reduced to 0” elsewhere in this file may be good ;)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree, but I don't think TRT and the other teams would appreciate sudden, unannounced test failures. It will create unnecessary noise, require extra triage resources, and potentially block CI for teams in other timezones while we aren't online to fix it.

I made a change to get logs like

job "serviceMonitor/openshift-apiserver/openshift-apiserver-operator-check-endpoints/0" has insecure_skip_verify=false (skip=true)
job "serviceMonitor/openshift-network-diagnostics/network-check-source/0" has insecure_skip_verify=false (skip=true)

once the bugs are fixed.

we can use those to update our tests.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

agree there, thanks for the explanation! lgtm!

@simonpasquier simonpasquier left a comment

Copy link
Copy Markdown
Contributor

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 Jul 16, 2026
@openshift-ci

openshift-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: machine424, 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

@openshift-trt

openshift-trt Bot commented Jul 16, 2026

Copy link
Copy Markdown

Risk analysis has seen new tests most likely introduced by this PR.
Please ensure that new tests meet guidelines for naming and stability.

New Test Risks for sha: 5115c57

Job Name New Test Risk
pull-ci-openshift-origin-main-e2e-metal-ipi-ovn-ipv6 Medium - "[sig-instrumentation][Late] Platform Prometheus targets should not skip TLS CA verification [Suite:openshift/conformance/parallel]" is a new test, and was only seen in one job.

New tests seen in this PR at sha: 5115c57

  • "[sig-instrumentation][Late] Platform Prometheus targets should not skip TLS CA verification [Suite:openshift/conformance/parallel]" [Total: 1, Pass: 1, Fail: 0, Flake: 0]

…tion

Scrape configs with insecure_skip_verify set to true do not validate
the target's TLS certificate, leaving the connection vulnerable to
man-in-the-middle attacks.
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 17, 2026
@openshift-ci

openshift-ci Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@openshift-ci

openshift-ci Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

@machine424: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-ovn-serial-2of2 e49f0f7 link true /test e2e-aws-ovn-serial-2of2
ci/prow/e2e-vsphere-ovn-upi e49f0f7 link true /test e2e-vsphere-ovn-upi
ci/prow/e2e-vsphere-ovn e49f0f7 link true /test e2e-vsphere-ovn
ci/prow/e2e-aws-ovn-serial-1of2 e49f0f7 link true /test e2e-aws-ovn-serial-1of2
ci/prow/e2e-gcp-ovn e49f0f7 link true /test e2e-gcp-ovn
ci/prow/e2e-aws-ovn-fips e49f0f7 link true /test e2e-aws-ovn-fips
ci/prow/e2e-aws-ovn-microshift e49f0f7 link true /test e2e-aws-ovn-microshift
ci/prow/e2e-metal-ipi-ovn-ipv6 e49f0f7 link true /test e2e-metal-ipi-ovn-ipv6

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.

@openshift-trt

openshift-trt Bot commented Jul 17, 2026

Copy link
Copy Markdown

Risk analysis has seen new tests most likely introduced by this PR.
Please ensure that new tests meet guidelines for naming and stability.

New tests seen in this PR at sha: e49f0f7

  • "[sig-instrumentation][Late] Platform Prometheus targets should not skip TLS CA verification [Suite:openshift/conformance/parallel]" [Total: 2, Pass: 2, Fail: 0, Flake: 0]

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. ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants