Skip to content

Fix controller metrics server race with serving-cert volume sync - #1010

Merged
yuumasato merged 2 commits into
openshift:masterfrom
Vincent056:fix-metrics-serving-cert-race
Jul 30, 2026
Merged

Fix controller metrics server race with serving-cert volume sync#1010
yuumasato merged 2 commits into
openshift:masterfrom
Vincent056:fix-metrics-serving-cert-race

Conversation

@Vincent056

Copy link
Copy Markdown
Contributor

What

Makes the custom :8585 controller metrics server wait (with exponential backoff, up to 5 minutes) for the serving-cert key pair to be synced into the container's volume mount before calling ListenAndServeTLS, propagates server failures to the manager instead of swallowing them, and shuts the server down cleanly when the manager context is canceled.

Why

TestMetricsHTTPVersion fails deterministically on e2e-aws (e.g. on #1003, and its skipped cleanup cascades into clusterrole already exists failures for every subsequent test). The failing curl gets exit 7 (connection refused) against https://metrics.<ns>.svc:8585/metrics-fio, and the operator log shows why:

{"logger":"metrics","msg":"Metrics service failed",
 "error":"open /var/run/secrets/serving-cert/tls.crt: no such file or directory"}

This is a regression from #845: before it, the operator exited and restarted when the serving-cert secret was missing, and by the time the container came back the kubelet had synced the cert files into the mount. Now the operator waits in-process — but only for the secret to exist in the API. Metrics.Start then does a one-shot ListenAndServeTLS before the kubelet has synced the files into the volume, fails, logs, and returns nil, so the metrics server never comes up and nothing restarts.

The fix mirrors the backoff pattern #845 introduced for the API-side checks, applied to the mounted files. Returning the error after the backoff is exhausted restores the old exit-and-restart behavior as a last resort instead of silently running without metrics.

🤖 Generated with Claude Code

Since the operator no longer exits and restarts when the metrics
serving-cert secret is missing (PR openshift#845), the custom :8585 metrics
server can start before the kubelet has synced the secret into the
container's volume mount. ListenAndServeTLS then fails once with
"open /var/run/secrets/serving-cert/tls.crt: no such file or
directory", the error is swallowed, and the metrics endpoint never
comes up — seen as curl exit 7 (connection refused) in
TestMetricsHTTPVersion and cascading e2e failures.

Wait for the cert key pair to appear in the mount with exponential
backoff before serving, propagate errors so the manager restarts the
pod as a last resort instead of silently running without metrics, and
shut the server down cleanly when the manager context is canceled.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2026
After the operator pod is killed, the node_failed gauges are restored
asynchronously by the configmap controller as each node's status is
re-reconciled (OCPBUGS-42807 path). The test polled only until any
file_integrity_operator_node metric appeared, slept a fixed 5 seconds,
and then asserted all nodes in one snapshot - failing when a node's
gauge had not been restored yet ("expected 1, got 0"). Poll for the
expected values instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@Vincent056: 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.

@yuumasato yuumasato 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 30, 2026
@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Vincent056, yuumasato

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:
  • OWNERS [Vincent056,yuumasato]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@yuumasato yuumasato added this to the 1.4.0 milestone Jul 30, 2026
@vickeybrown

Copy link
Copy Markdown

/verified bypass

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jul 30, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@vickeybrown: The verified label has been added.

Details

In response to this:

/verified bypass

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.

@vickeybrown

Copy link
Copy Markdown

/verified remove

@openshift-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Jul 30, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@vickeybrown: The verified label has been removed.

Details

In response to this:

/verified remove

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.

@vickeybrown

Copy link
Copy Markdown

/verified by e2e-aws test

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jul 30, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@vickeybrown: This PR has been marked as verified by e2e-aws test.

Details

In response to this:

/verified by e2e-aws test

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.

@yuumasato

Copy link
Copy Markdown
Contributor

Manually merging so we can move forward with FIO v1.4.0 release.

@yuumasato
yuumasato merged commit c8b0073 into openshift:master Jul 30, 2026
7 of 9 checks passed
@GroceryBoyJr

Copy link
Copy Markdown

/assign docs-approved

@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@GroceryBoyJr: GitHub didn't allow me to assign the following users: docs-approved.

Note that only openshift members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

Details

In response to this:

/assign docs-approved

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.

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.

5 participants