Skip to content

OPNET-603: Fail haproxy test when all kubeapi servers are down simultaneously#31291

Open
mkowalski wants to merge 1 commit into
openshift:mainfrom
mkowalski:opnet-603-haproxy-full-outage-test
Open

OPNET-603: Fail haproxy test when all kubeapi servers are down simultaneously#31291
mkowalski wants to merge 1 commit into
openshift:mainfrom
mkowalski:opnet-603-haproxy-full-outage-test

Conversation

@mkowalski

@mkowalski mkowalski commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Implements https://issues.redhat.com/browse/OPNET-603 (mirrored at https://redhat.atlassian.net/browse/OPNET-603).

The on-prem haproxy monitor test added in #29149 so far only flaked when haproxy detected individual kube-apiserver backends as down, which is expected over the course of installation or upgrade. As suggested in #29149 (comment), what really matters is whether a single haproxy instance saw all kube-apiserver backends down at the same time, because that means the API was completely unreachable through the on-prem loadbalancer.

Changes:

  • findFullAPIOutageWindows(): sweeps over the constructed OnPremHaproxyDetectsDown intervals per haproxy instance, counting how many distinct kube-apiserver backends are concurrently down; windows with at least 3 backends down (on-prem HA control plane size) are full API outages. A backend recovering the same second another goes down is not counted as overlap, and touching windows are merged so a same-second flap does not split one outage into two.
  • evaluateFullAPIOutages(): new junit test [Jira: Networking / On-Prem Host Networking] Haproxy must not detect all kubeapi servers down simultaneously. The first outage window for every haproxy instance is tolerated, since when haproxy starts during the installation all kube-apiservers are expected to be down until they come up for the first time. Any subsequent window fails the test with the node, time range and duration in the output.
  • The existing flaky reachability test is left unchanged; the new result is appended in EvaluateTestsFromConstructedIntervals.
  • Unit tests covering the sweep semantics (threshold, per-instance isolation, boundary/merge edge cases) and the junit evaluation (install-only tolerance, post-install failure).

Verified with go build, go vet and go test ./pkg/monitortests/network/onpremhaproxy/... (all tests pass).

Summary by CodeRabbit

  • New Features

    • Enhanced on-premises HAProxy monitoring to detect and report full API outages when multiple kube-apiserver backends are simultaneously unavailable, in addition to existing partial outage detection.
  • Tests

    • Added comprehensive test suites validating the new full outage detection logic, including scenarios with multiple backends, partial overlaps, simultaneous failures, and boundary-touching intervals.

…aneously

The on-prem haproxy monitor test so far only flaked when haproxy
detected individual kube-apiserver backends as down, which is expected
over the course of installation or upgrade. What really matters is
whether at any point in time a single haproxy instance saw all
kube-apiserver backends down at the same time, because that means the
API was completely unreachable through the on-prem loadbalancer.

Add a sweep over the constructed OnPremHaproxyDetectsDown intervals
that finds, per haproxy instance, the time windows during which at
least three distinct backends were down simultaneously. The first such
window for every haproxy instance is tolerated, because when haproxy
starts during the installation all kube-apiservers are expected to be
down until they come up for the first time. Any subsequent window
fails the new junit test.

Implements Ben's suggestion from
openshift#29149 (comment)
@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-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 11, 2026
@openshift-ci-robot

openshift-ci-robot commented Jun 11, 2026

Copy link
Copy Markdown

@mkowalski: This pull request references OPNET-603 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Implements https://issues.redhat.com/browse/OPNET-603 (mirrored at https://redhat.atlassian.net/browse/OPNET-603).

The on-prem haproxy monitor test added in #29149 so far only flaked when haproxy detected individual kube-apiserver backends as down, which is expected over the course of installation or upgrade. As suggested in #29149 (comment), what really matters is whether a single haproxy instance saw all kube-apiserver backends down at the same time, because that means the API was completely unreachable through the on-prem loadbalancer.

Changes:

  • findFullAPIOutageWindows(): sweeps over the constructed OnPremHaproxyDetectsDown intervals per haproxy instance, counting how many distinct kube-apiserver backends are concurrently down; windows with at least 3 backends down (on-prem HA control plane size) are full API outages. A backend recovering the same second another goes down is not counted as overlap, and touching windows are merged so a same-second flap does not split one outage into two.
  • evaluateFullAPIOutages(): new junit test [Jira: Networking / On-Prem Host Networking] Haproxy must not detect all kubeapi servers down simultaneously. The first outage window for every haproxy instance is tolerated, since when haproxy starts during the installation all kube-apiservers are expected to be down until they come up for the first time. Any subsequent window fails the test with the node, time range and duration in the output.
  • The existing flaky reachability test is left unchanged; the new result is appended in EvaluateTestsFromConstructedIntervals.
  • Unit tests covering the sweep semantics (threshold, per-instance isolation, boundary/merge edge cases) and the junit evaluation (install-only tolerance, post-install failure).

Verified with go build, go vet and go test ./pkg/monitortests/network/onpremhaproxy/... (all tests pass).

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.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

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: 06a4703c-1a1b-40f2-83d8-6abfda92bed7

📥 Commits

Reviewing files that changed from the base of the PR and between bde16f5 and 871e3e8.

📒 Files selected for processing (2)
  • pkg/monitortests/network/onpremhaproxy/monitortest.go
  • pkg/monitortests/network/onpremhaproxy/monitortest_test.go

Walkthrough

The PR extends on-prem HAProxy network monitoring to detect full kube-apiserver backend outages. It adds interval-window computation logic that groups backend-down events by HAProxy node, sweeps time to find concurrent-backend outage windows, merges overlapping windows, and appends JUnit test results that fail only when multiple backends are simultaneously unavailable after the startup phase.

Changes

Full API Outage Detection for HAProxy

Layer / File(s) Summary
Full outage detection implementation and integration
pkg/monitortests/network/onpremhaproxy/monitortest.go
Adds sort import, implements findFullAPIOutageWindows to compute and merge time-swept windows where at least 3 backends are concurrently down per HAProxy node, adds evaluateFullAPIOutages to emit JUnit test results that fail on post-startup full outages, and integrates both into EvaluateTestsFromConstructedIntervals result assembly.
Test coverage for outage detection
pkg/monitortests/network/onpremhaproxy/monitortest_test.go
Provides test setup helpers (testStart, at, haproxyDownInterval), TestFindFullAPIOutageWindows with scenarios covering overlapping/non-overlapping backend failures and multiple HAProxy instances, and TestEvaluateFullAPIOutages validating pass/fail behavior across installation-time and post-startup outage windows.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and specifically identifies the main change: detecting and failing the haproxy test when all kube-apiserver backends are simultaneously down, which directly aligns with the core functionality added in the changeset.
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 All test names in the PR are stable and deterministic. JUnit test names are static strings with no dynamic content. Go test subtitles use hardcoded descriptive strings, not generated values like ti...
Test Structure And Quality ✅ Passed Tests are standard Go table-driven tests using testing.T, not Ginkgo tests. The custom check is for Ginkgo test code, so it is not applicable here.
Microshift Test Compatibility ✅ Passed This PR does not add any Ginkgo e2e tests. It adds standard Go unit tests (TestFindFullAPIOutageWindows, TestEvaluateFullAPIOutages) and updates monitor test framework code that programmatically ge...
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR adds monitor tests, not Ginkgo e2e tests. The custom check applies only to Ginkgo e2e tests (It(), Describe(), etc.). Monitor tests are a different framework and these functions contain no multi...
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies monitoring test code (not deployment manifests or operator code) to analyze HAProxy outage intervals. The constant fullOutageBackendThreshold=3 is analysis logic, not a scheduling const...
Ote Binary Stdout Contract ✅ Passed No unfiltered stdout writes detected in process-level code. All fmt.Sprint/Sprintf calls are for data construction within interface methods, not stdout. No init(), main(), or suite-level setup with...
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR adds standard Go unit tests and MonitorTest implementations, not Ginkgo e2e tests. The check targets Ginkgo e2e tests specifically, so it is not applicable.
No-Weak-Crypto ✅ Passed No weak cryptographic algorithms (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB), custom crypto implementations, or non-constant-time secret comparisons found in the PR files. The code contains no crypt...
Container-Privileges ✅ Passed PR modifies only Go test files (monitortest.go/.go); contains no container/K8s manifests or privilege-related configurations (privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, allowPrivilegeEsc...
No-Sensitive-Data-In-Logs ✅ Passed The PR extracts only specific HAProxy server status fields via regex and outputs only structured data (node names, timestamps, durations). No sensitive information like passwords, tokens, keys, PII...

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci Bot requested review from deads2k and p0lyn0mial June 11, 2026 15:57
@openshift-ci

openshift-ci Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mkowalski

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 Jun 11, 2026
@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 Jun 11, 2026
@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 Jun 11, 2026

Copy link
Copy Markdown
Contributor

@mkowalski: 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-vsphere-ovn-upi 871e3e8 link true /test e2e-vsphere-ovn-upi
ci/prow/e2e-gcp-ovn-upgrade 871e3e8 link true /test e2e-gcp-ovn-upgrade
ci/prow/e2e-gcp-ovn 871e3e8 link true /test e2e-gcp-ovn
ci/prow/e2e-aws-ovn-serial-1of2 871e3e8 link true /test e2e-aws-ovn-serial-1of2
ci/prow/e2e-vsphere-ovn 871e3e8 link true /test e2e-vsphere-ovn
ci/prow/e2e-aws-ovn-serial-2of2 871e3e8 link true /test e2e-aws-ovn-serial-2of2
ci/prow/e2e-aws-ovn-fips 871e3e8 link true /test e2e-aws-ovn-fips
ci/prow/e2e-metal-ipi-ovn-ipv6 871e3e8 link true /test e2e-metal-ipi-ovn-ipv6
ci/prow/e2e-aws-ovn-microshift-serial 871e3e8 link true /test e2e-aws-ovn-microshift-serial
ci/prow/e2e-aws-ovn-microshift 871e3e8 link true /test e2e-aws-ovn-microshift

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 Jun 11, 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: 871e3e8

  • "[Monitor:on-prem-haproxy][Jira: Networking / On-Prem Host Networking] Haproxy must not detect all kubeapi servers down simultaneously" [Total: 12, Pass: 12, 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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. 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.

2 participants