Skip to content

VR: fix haproxy check when ssl offloading is configured - #12596

Open
weizhouapache wants to merge 7 commits into
apache:4.22from
weizhouapache:4.22-vr-fix-haproxy-check-with-ssl-offloading
Open

weizhouapache wants to merge 7 commits into
apache:4.22from
weizhouapache:4.22-vr-fix-haproxy-check-with-ssl-offloading

Conversation

@weizhouapache

Copy link
Copy Markdown
Member

Description

This PR fixes #12591

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@boring-cyborg boring-cyborg Bot added component:virtual-router Python Warning... Python code Ahead! labels Feb 5, 2026
@codecov

codecov Bot commented Feb 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 18.33%. Comparing base (7aa0558) to head (9e880e5).
⚠️ Report is 388 commits behind head on 4.22.

Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #12596      +/-   ##
============================================
+ Coverage     17.61%   18.33%   +0.72%     
- Complexity    15664    16664    +1000     
============================================
  Files          5917     5939      +22     
  Lines        531402   537819    +6417     
  Branches      64971    65941     +970     
============================================
+ Hits          93596    98613    +5017     
- Misses       427252   427987     +735     
- Partials      10554    11219     +665     
Flag Coverage Δ
uitests 4.08% <ø> (+0.37%) ⬆️
unittests 19.42% <ø> (+0.74%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DaanHoogland DaanHoogland added this to the 4.22.1 milestone Feb 5, 2026
@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

1 similar comment
@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan test

Copilot AI 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.

Pull request overview

This PR addresses issue #12591 by adjusting the SystemVM HAProxy advanced health check to tolerate additional bind options appended when SSL offloading is configured, avoiding false health check failures while keeping HAProxy config validation intact.

Changes:

  • Relax bind line matching in haproxy_check.py to accept bind <ip:port> ... (with trailing options) rather than requiring an exact string match.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan test

@rajujith rajujith moved this to In Progress in Apache CloudStack 4.22.1 Feb 13, 2026
@weizhouapache
weizhouapache marked this pull request as ready for review February 19, 2026 13:57
@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@DaanHoogland DaanHoogland linked an issue Mar 5, 2026 that may be closed by this pull request
@weizhouapache

Copy link
Copy Markdown
Member Author

@DaanHoogland @sureshanaparti
can you please review ?

cc @borisstoyanov

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

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

still looks good

@rajujith

Copy link
Copy Markdown
Contributor

@weizhouapache I see this error on healthcheck
Screenshot 2026-04-10 at 1 07 04 PM

@DaanHoogland DaanHoogland moved this from Backlog to Ready in CloudStack Testing Aug 31, 2026
@DaanHoogland DaanHoogland moved this from Ready to conflict/waiting for author in CloudStack Testing Aug 31, 2026
@weizhouapache weizhouapache moved this from conflict/waiting to Ready in CloudStack Testing Sep 7, 2026
@vladimirpetrov vladimirpetrov self-assigned this Sep 9, 2026
@nvazquez nvazquez modified the milestones: 4.22.2, 4.22.3 Nov 9, 2026
@sureshanaparti sureshanaparti modified the milestones: 4.22.3, 4.22.2 Nov 23, 2026

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

clgtm

@vladimirpetrov

Copy link
Copy Markdown
Contributor

I tested this PR on KVM and the current head (12ff7a3) does not fix #12591: haproxy_check.py still fails for every SSL-offloaded LB rule.

Cause

cfgSection["bind"][0] is the text after the bind keyword, so for an SSL rule it is:

10.0.62.24:443 ssl crt /etc/cloudstack/ssl/10_0_62_24-443.pem alpn h2,http/1.1 ssl-min-ver TLSv1.2 ...

" ".join(bind_line.split()[:2]) therefore gives 10.0.62.24:443 ssl, which never equals bindStr (10.0.62.24:443). Only bind lines without options pass, and those already passed before the PR. The previous commit (9a312bd, split()[0]) was correct.

Steps to reproduce (isolated network, VR running)

  1. Create an LB rule protocol=ssl publicport=443 privateport=80 and assign a VM to it.
  2. uploadSslCert any self-signed cert, then assignCertToLoadBalancer on the rule.
  3. Run getRouterHealthCheckResults routerid=<vr> performfreshchecks=true.

Result: haproxy_check.py is FAILED:

Incorrect bind string found. Expected 10.0.62.24:443 but found 10.0.62.24:443 ssl crt /etc/cloudstack/ssl/10_0_62_24-443.pem alpn h2,http/1.1 ssl-min-ver TLSv1.2 no-tls-tickets ciphers ... .

A ROUTER.HEALTH.CHECKS event and alert are raised, as without the PR.

Results

Scenario 4.22.1.1 (no PR) With this PR
SSL rule, cert assigned (fresh check) FAILED FAILED
Same, scheduled check (cron, no fresh run) FAILED FAILED
After VR reboot FAILED FAILED
Two SSL listeners (443 + 8443) FAILED for both FAILED for both
VPC VR, SSL rule on a tier FAILED FAILED
Plain TCP rule, or ssl rule without a cert SUCCESS SUCCESS

I confirmed that the VR runs the script from this PR: its md5 matches the copy in the management server's cloud-scripts.tgz, and that copy contains the PR hunk.

Direct run on the same VR, same haproxy.cfg and health_checks_data.json

Input Script from this PR Same script with split()[0]
plain bind pass pass
SSL bind (real config) fail (rc=1, message above) pass
SSL bind on wrong port (:4430) fail fail (correctly)

Suggested fix

bind_line = cfgSection["bind"][0]
bind_token = bind_line.split()[0] if bind_line else ""
if bind_token != bindStr:

This passes SSL binds and still catches a wrong IP or port. A small unit test in systemvm/test/ would help: one plain bind, one SSL bind with the full option string, and one with the wrong port.

Not a blocker: even with the fix, the check never verifies the SSL options. A bind line without ssl crt ... passes although haproxyData contains sslcert=. This may be worth a separate follow-up.

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

Cover plain bind, SSL bind with options, and wrong port/IP cases for
checkLoadBalance in haproxy_check.py, so the SSL-offloading regression
reported in apache#12591 is caught by unit tests.
@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20197

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20198

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@vladimirpetrov vladimirpetrov 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, all tests passed with the latest change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Ready

Development

Successfully merging this pull request may close these issues.

haproxy_check.py does not validate SSL config correctly

9 participants