Skip to content

Retire metrics-proxy self-test and its integration test#528

Merged
frobware merged 2 commits into
bpfman:mainfrom
frobware:metrics-proxy-retire-self-test
May 19, 2026
Merged

Retire metrics-proxy self-test and its integration test#528
frobware merged 2 commits into
bpfman:mainfrom
frobware:metrics-proxy-retire-self-test

Conversation

@frobware
Copy link
Copy Markdown
Contributor

@frobware frobware commented May 18, 2026

This addresses #527 by retiring the metrics-proxy self-test in two commits. The first removes test/integration/metrics_test.go, which has been t.Skip-ing on every nightly run because the upstream KIND cluster doesn't install the prometheus-operator CRDs that the bpfman-operator gates the metrics-proxy DaemonSet reconcile on. The second removes the matching /metrics-proxy test subcommand from the production binary, along with the bootstrap-and-pin TLS pattern that SAST tooling has been flagging.

podExec was the only piece of metrics_test.go with another caller (common.go uses it for link-ordering checks), so it moves into common.go. Everything else -- the dispatcher in cmd/metrics-proxy/main.go, the runSelfTests/testHealthEndpoint/testMetricsEndpoint/getServerCertPool/outputResults helpers, the TestResult/TestResults JSON types, and the ServiceAccount/token plumbing in the test file -- goes away. Net effect is roughly -560 lines of code that ships in the agent image but never runs, and the SAST finding goes with it.

If a downstream consumer (e.g. openshift/bpfman-operator) deploys with prometheus-operator CRDs installed and wants metrics coverage in their CI, that test lives more naturally in their tree than as an always-skipping test here. Happy to discuss alternatives if you'd rather keep the test in place with a different fix.

Test plan

  • make build and make test pass
  • Integration test suite still compiles: go test -c -tags integration_tests ./test/integration/
  • Nightly integration job (.github/workflows/integration_test.yml) passes on the remaining tests (app_test.go, kprobe_test.go, tc_test.go, tcx_test.go, tracepoint_test.go, uprobe_test.go, xdp_test.go)

frobware added 2 commits May 18, 2026 16:21
The metrics-proxy self-test driver in test/integration/metrics_test.go
never runs in upstream CI. The nightly KIND cluster does not install
the prometheus-operator CRDs, so monitoring.coreos.com is absent. The
bpfman-operator gates its metrics-proxy DaemonSet reconcile on that
API group (controllers/bpfman-operator/config.go:328) and the test
guards itself with the same check, hitting t.Skip on every nightly
run.

Delete metrics_test.go and move its podExec helper to common.go,
which also uses podExec for link-ordering checks. The rest of the
test file -- ServiceAccount/token plumbing, pod selector,
agentMetricTestResult JSON types -- goes with the file.

See bpfman#527.

Signed-off-by: Andrew McDermott <amcdermo@redhat.com>
The /metrics-proxy test subcommand exists solely to be kubectl exec'd
by an integration test that has now been retired. Delete the
argv[1] == "test" dispatcher and all the code it reached:
runSelfTests, testHealthEndpoint, testMetricsEndpoint,
getServerCertPool, outputResults, and the TestResult/TestResults JSON
types.

The self-test's TLS verification was theatre. It dialled
localhost:8443 with InsecureSkipVerify: true, scraped the peer cert,
built a RootCAs pool, then performed the real request with
InsecureSkipVerify: false. The bootstrap dial trusted whatever
certificate the peer presented, so the subsequent "verified" call
only confirmed that the second peer matched the first. If the
bootstrap failed the code fell back silently to InsecureSkipVerify:
true.

See bpfman#527.

Signed-off-by: Andrew McDermott <amcdermo@redhat.com>
@frobware
Copy link
Copy Markdown
Contributor Author

cc @alebedev87

Comment thread test/integration/metrics_test.go
@alebedev87
Copy link
Copy Markdown
Contributor

/lgtm

@frobware frobware merged commit c0bfd0f into bpfman:main May 19, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants