Skip to content

[release-4.22] OCPBUGS-109638: Fix clock_state metric: HOLDOVER mapped to 0, stale when CEP enabled - #636

Open
jzding wants to merge 1 commit into
openshift:release-4.22from
jzding:fix-holdover-metric-4.22
Open

[release-4.22] OCPBUGS-109638: Fix clock_state metric: HOLDOVER mapped to 0, stale when CEP enabled#636
jzding wants to merge 1 commit into
openshift:release-4.22from
jzding:fix-holdover-metric-4.22

Conversation

@jzding

@jzding jzding commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Backport of upstream PR k8snetworkplumbingwg/linuxptp-daemon#250 to release-4.22.

Two fixes for the openshift_ptp_clock_state Prometheus metric:

  • HOLDOVER mapped to 0 instead of 2updateClockStateMetrics only distinguished LOCKED (1) from everything else (0). HOLDOVER was indistinguishable from FREERUN despite the help text declaring 0 = FREERUN, 1 = LOCKED, 2 = HOLDOVER. Replaced the if/else with a switch using typed constants shared between metrics.go and event.go.

  • Metric stale when CEP enabledEventHandler.UpdateClockStateMetrics was guarded by if e.stdoutToSocket { return }, skipping Prometheus updates when cloud-event-proxy was enabled. Since CEP does not register its own openshift_ptp_clock_state gauge, this left the metric stale. Removed the guard so the metric is always updated.

Fixes: OCPBUGS-95587

Test plan

  • TestUpdateClockStateMetrics — verifies FREERUN→0, LOCKED→1, HOLDOVER→2
  • go build ./... passes
  • Lab tested on cnfdg32 (OCP 4.22) with upstream PR

Two issues with the openshift_ptp_clock_state Prometheus metric:

1. updateClockStateMetrics in metrics.go mapped HOLDOVER to 0 (same as
   FREERUN), making the two states indistinguishable. The help text
   declares "0 = FREERUN, 1 = LOCKED, 2 = HOLDOVER". Replace the
   if/else with a switch using typed constants (ClockStateFreerun,
   ClockStateLocked, ClockStateHoldover) defined in pkg/event and
   shared by both metrics.go and event.go, matching the pattern in
   cloud-event-proxy.

2. EventHandler.UpdateClockStateMetrics in event.go was guarded by
   `if e.stdoutToSocket { return }`, skipping Prometheus updates when
   cloud-event-proxy was enabled. Since CEP does not register its own
   Prometheus metrics, this left the gauge stale. Remove the guard so
   the metric is always updated regardless of CEP mode.

Fixes: OCPBUGS-95587

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Jack Ding <jackding@gmail.com>
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 24, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jzding: This pull request references Jira Issue OCPBUGS-95587, which is invalid:

  • expected the bug to be open, but it isn't
  • expected the bug to target either version "4.22.0." or "openshift-4.22.0.", but it targets "5.0.0" instead
  • expected the bug to be in one of the following states: NEW, ASSIGNED, POST, but it is Closed (Done) instead
  • release note text must be set and not match the template OR release note type must be set to "Release Note Not Required". For more information you can reference the OpenShift Bug Process.
  • expected Jira Issue OCPBUGS-95587 to depend on a bug targeting a version in 5.0.0 and in one of the following states: MODIFIED, ON_QA, VERIFIED, but no dependents were found

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Summary

Backport of upstream PR k8snetworkplumbingwg/linuxptp-daemon#250 to release-4.22.

Two fixes for the openshift_ptp_clock_state Prometheus metric:

  • HOLDOVER mapped to 0 instead of 2updateClockStateMetrics only distinguished LOCKED (1) from everything else (0). HOLDOVER was indistinguishable from FREERUN despite the help text declaring 0 = FREERUN, 1 = LOCKED, 2 = HOLDOVER. Replaced the if/else with a switch using typed constants shared between metrics.go and event.go.

  • Metric stale when CEP enabledEventHandler.UpdateClockStateMetrics was guarded by if e.stdoutToSocket { return }, skipping Prometheus updates when cloud-event-proxy was enabled. Since CEP does not register its own openshift_ptp_clock_state gauge, this left the metric stale. Removed the guard so the metric is always updated.

Fixes: OCPBUGS-95587

Test plan

  • TestUpdateClockStateMetrics — verifies FREERUN→0, LOCKED→1, HOLDOVER→2
  • go build ./... passes
  • Lab tested on cnfdg32 (OCP 4.22) with upstream PR

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.

@openshift-ci

openshift-ci Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jzding

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-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 24, 2026
@openshift-ci

openshift-ci Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

@jzding: 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/unit-test 9fb37ff link true /test unit-test
ci/prow/gofmt 9fb37ff link true /test gofmt

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.

@jzding jzding changed the title OCPBUGS-95587: Fix clock_state metric: HOLDOVER mapped to 0, stale when CEP enabled [release-4.22] OCPBUGS-95587: Fix clock_state metric: HOLDOVER mapped to 0, stale when CEP enabled Aug 24, 2026
@jzding jzding changed the title [release-4.22] OCPBUGS-95587: Fix clock_state metric: HOLDOVER mapped to 0, stale when CEP enabled [release-4.22] OCPBUGS-109638: Fix clock_state metric: HOLDOVER mapped to 0, stale when CEP enabled Aug 24, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jzding: This pull request references Jira Issue OCPBUGS-109638, which is invalid:

  • release note text must be set and not match the template OR release note type must be set to "Release Note Not Required". For more information you can reference the OpenShift Bug Process.
  • expected dependent Jira Issue OCPBUGS-95587 to be in one of the following states: MODIFIED, ON_QA, VERIFIED, but it is Closed (Done) instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Summary

Backport of upstream PR k8snetworkplumbingwg/linuxptp-daemon#250 to release-4.22.

Two fixes for the openshift_ptp_clock_state Prometheus metric:

  • HOLDOVER mapped to 0 instead of 2updateClockStateMetrics only distinguished LOCKED (1) from everything else (0). HOLDOVER was indistinguishable from FREERUN despite the help text declaring 0 = FREERUN, 1 = LOCKED, 2 = HOLDOVER. Replaced the if/else with a switch using typed constants shared between metrics.go and event.go.

  • Metric stale when CEP enabledEventHandler.UpdateClockStateMetrics was guarded by if e.stdoutToSocket { return }, skipping Prometheus updates when cloud-event-proxy was enabled. Since CEP does not register its own openshift_ptp_clock_state gauge, this left the metric stale. Removed the guard so the metric is always updated.

Fixes: OCPBUGS-95587

Test plan

  • TestUpdateClockStateMetrics — verifies FREERUN→0, LOCKED→1, HOLDOVER→2
  • go build ./... passes
  • Lab tested on cnfdg32 (OCP 4.22) with upstream PR

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.

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. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants