Skip to content

HYPERFLEET-1493 - fix: eliminate CPU-contention flakes in perf latency specs - #157

Open
kuudori wants to merge 1 commit into
openshift-hyperfleet:mainfrom
kuudori:HYPERFLEET-1493-perf-flake-fix
Open

HYPERFLEET-1493 - fix: eliminate CPU-contention flakes in perf latency specs#157
kuudori wants to merge 1 commit into
openshift-hyperfleet:mainfrom
kuudori:HYPERFLEET-1493-perf-flake-fix

Conversation

@kuudori

@kuudori kuudori commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Mark ms-scale perf latency specs (channel/version/wifconfig/cluster create/update/list/delete/read) ginkgo.Serial so Ginkgo's parallel procs don't contend for CPU and skew the threshold assertions
  • Extract shared median-of-N sampling into helper.MeasureMedianLatency, replacing hand-rolled timing code duplicated across 18 spec files
  • Mint the suite JWT once via SynchronizedBeforeSuite instead of once per parallel process
  • Add DeferChannelCleanup/DeferWifConfigCleanup helpers alongside the existing DeferClusterCleanup

Test plan

  • make check (generate, fmt-check, vet, lint, test) passes locally
  • New unit tests for MeasureMedianLatency (sampling count, threshold pass/fail, median-not-mean)

@openshift-ci
openshift-ci Bot requested a review from sherine-k August 11, 2026 00:00
@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ciaranroche for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 requested a review from tirthct August 11, 2026 00:00
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 90b83ef2-fc00-41eb-b778-36dea744452e

📥 Commits

Reviewing files that changed from the base of the PR and between 9e5ba16 and 4d92809.

📒 Files selected for processing (2)
  • pkg/helper/perf.go
  • pkg/helper/perf_test.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/helper/perf.go

📝 Walkthrough

Summary by CodeRabbit

  • Performance

    • Improved latency checks by measuring median response times across multiple samples.
    • Serialized timing-sensitive performance tests for more consistent results.
    • Expanded coverage across channel, cluster, version, and WIF configuration operations.
  • Reliability

    • Improved test-suite setup consistency during parallel execution.
    • Added automatic cleanup for created test resources.
  • Documentation

    • Updated guidance for serial performance tests and nightly baseline recalibration.

Walkthrough

The PR adds shared median-latency measurement with five default samples. Channel, cluster, version, and WIFConfig performance suites now run serially and use the shared helper. Delete tests measure multiple resources. Deferred cleanup helpers handle channels and WIFConfigs. E2E suite initialization shares the JWT from process 1. Documentation and threshold guidance describe serial Tier1 nightly performance tests.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PerformanceSpec
  participant MeasureMedianLatency
  participant API
  PerformanceSpec->>MeasureMedianLatency: provide threshold and sample callback
  MeasureMedianLatency->>API: execute sampled API request
  API-->>MeasureMedianLatency: return request result
  MeasureMedianLatency-->>PerformanceSpec: log median and assert threshold
Loading

Suggested reviewers: sherine-k, tirthct

🚥 Pre-merge checks | ✅ 10 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
No Pii Or Sensitive Data In Logs ⚠️ Warning New cleanup warnings log %v errors; HTTPError.Error includes raw response bodies, which may contain customer data (CWE-532). Redact or omit HTTP response bodies before logging cleanup errors. Log only status codes and safe operation identifiers.
✅ Passed checks (10 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: reducing CPU-contention flakes in performance latency specifications.
Description check ✅ Passed The description accurately covers serial performance specs, shared latency sampling, suite JWT reuse, cleanup helpers, and unit tests.
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.
Sec-02: Secrets In Log Output ✅ Passed No log call emits a token, password, credential, or secret value; suite logging contains only JWT metadata. Credential-bearing URLs are redacted. CWE-532 not observed.
No Hardcoded Secrets ✅ Passed No hardcoded credentials were added; the JWT comes from Kubernetes CreateToken, and scans found no private keys, known token formats, URL credentials, or base64 secrets in configuration.
No Weak Cryptography ✅ Passed The patch adds no banned primitive, ECB mode, custom crypto, or secret comparison. Repository crypto use is crypto/rand and SHA-256 for a non-security Helm-name suffix.
No Injection Vectors ✅ Passed Changed Go files contain no exec.Command, SQL Query/Exec, yaml.Unmarshal, or template.HTML calls; fmt.Sprintf uses only test indices/constants, so no CWE-78/79/89/502 vector is introduced.
No Privileged Containers ✅ Passed The PR changes no manifests, Helm templates, or Dockerfiles. Added lines contain no privilege indicators. Existing USER root lines predate the PR and install tools; the platform image uses UID 1000.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@e2e/channel/perf_update_latency.go`:
- Around line 38-48: Vary the PATCH payload on every sample so each measured
request performs a real update rather than becoming a no-op. Update the callback
in e2e/channel/perf_update_latency.go:38-48,
e2e/version/perf_update_latency.go:46-58, and
e2e/wifconfig/perf_update_latency.go:38-48 to use the callback’s iteration value
and assign a distinct valid field value for each sample while preserving the
existing PATCH and latency-measurement flow.

In `@pkg/helper/perf.go`:
- Around line 27-36: Validate n at the start of MeasureMedianLatency before
allocation, reject non-positive counts, and calculate the true median for even
counts by averaging both middle durations (or explicitly enforce odd counts).
Add table-driven tests in pkg/helper/perf_test.go covering zero, negative, and
even sample counts, including the expected error or behavior for each case.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: da7a54c2-cc53-494b-b35b-6808c48def7d

📥 Commits

Reviewing files that changed from the base of the PR and between d1e8e61 and 63e38b8.

📒 Files selected for processing (24)
  • docs/development.md
  • e2e/channel/perf_create_latency.go
  • e2e/channel/perf_delete_latency.go
  • e2e/channel/perf_get_latency.go
  • e2e/channel/perf_list_latency.go
  • e2e/channel/perf_update_latency.go
  • e2e/cluster/perf_list_filtered_latency.go
  • e2e/cluster/perf_list_latency.go
  • e2e/cluster/perf_read_entity_size_latency.go
  • e2e/version/perf_create_latency.go
  • e2e/version/perf_delete_latency.go
  • e2e/version/perf_get_latency.go
  • e2e/version/perf_list_latency.go
  • e2e/version/perf_update_latency.go
  • e2e/wifconfig/perf_create_latency.go
  • e2e/wifconfig/perf_delete_latency.go
  • e2e/wifconfig/perf_get_latency.go
  • e2e/wifconfig/perf_list_latency.go
  • e2e/wifconfig/perf_update_latency.go
  • pkg/config/thresholds.go
  • pkg/e2e/suite.go
  • pkg/helper/helper.go
  • pkg/helper/perf.go
  • pkg/helper/perf_test.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)

Comment thread e2e/channel/perf_update_latency.go
Comment thread pkg/helper/perf.go
@kuudori
kuudori force-pushed the HYPERFLEET-1493-perf-flake-fix branch from 63e38b8 to 9e5ba16 Compare August 11, 2026 03:14

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@pkg/helper/perf_test.go`:
- Around line 11-13: Update TestMeasureMedianLatency to replace time.Sleep-based
timing with an internal clock or duration-measurement seam that accepts scripted
durations. Add assertions for durations exactly equal to the threshold, and for
even-sized samples test thresholds that distinguish lower-middle from
upper-middle selection. Preserve coverage of sampling, threshold behavior,
median calculation, and relevant error paths through the seam.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: ff719dc9-880f-4be6-8dc6-27b1e4a7df27

📥 Commits

Reviewing files that changed from the base of the PR and between 63e38b8 and 9e5ba16.

📒 Files selected for processing (5)
  • e2e/channel/perf_update_latency.go
  • e2e/version/perf_update_latency.go
  • e2e/wifconfig/perf_update_latency.go
  • pkg/helper/perf.go
  • pkg/helper/perf_test.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)
🚧 Files skipped from review as they are similar to previous changes (4)
  • pkg/helper/perf.go
  • e2e/version/perf_update_latency.go
  • e2e/channel/perf_update_latency.go
  • e2e/wifconfig/perf_update_latency.go

Comment thread pkg/helper/perf_test.go Outdated
…y specs

- Mark ms-scale perf latency specs (channel/version/wifconfig/cluster
  create/update/list/delete/read) ginkgo.Serial so Ginkgo's parallel
  procs don't contend for CPU and skew the threshold assertions
- Extract shared median-of-N sampling into helper.MeasureMedianLatency,
  replacing hand-rolled timing code duplicated across 18 spec files
- Split the median/threshold assertion out of MeasureMedianLatency into
  assertMedianBelowThreshold so its unit tests exercise the math with
  exact durations instead of time.Sleep, removing the last source of
  CPU-contention flakiness in this package's own test suite
- Mint the suite JWT once via SynchronizedBeforeSuite instead of once
  per parallel process
- Add DeferChannelCleanup/DeferWifConfigCleanup helpers alongside the
  existing DeferClusterCleanup
@kuudori
kuudori force-pushed the HYPERFLEET-1493-perf-flake-fix branch from 9e5ba16 to 4d92809 Compare August 11, 2026 03:53
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.

1 participant