vladimirpetrov commented on PR #12596:
URL: https://github.com/apache/cloudstack/pull/12596#issuecomment-7198242302

   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**
   
   ```python
   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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to