Copilot commented on code in PR #12596:
URL: https://github.com/apache/cloudstack/pull/12596#discussion_r2778073227


##########
systemvm/debian/root/health_checks/haproxy_check.py:
##########
@@ -50,7 +50,7 @@ def checkLoadBalance(haproxyData, haCfgSections):
                     correct = False
 
                 bindStr = lbSec["sourceIp"] + ":" + 
formatPort(lbSec["sourcePortStart"], lbSec["sourcePortEnd"])
-                if cfgSection["bind"][0] != bindStr:
+                if not cfgSection["bind"][0].startswith(bindStr):

Review Comment:
   Using `startswith(bindStr)` can incorrectly accept mismatched ports (e.g., 
expected `1.2.3.4:80` but config has `1.2.3.4:8000`, which still starts with 
`1.2.3.4:80`). To allow extra HAProxy bind options while keeping correctness, 
compare only the first whitespace-delimited token of the bind directive (or 
otherwise parse the address:port portion) instead of a raw prefix match.
   ```suggestion
                   bind_line = cfgSection["bind"][0]
                   bind_token = bind_line.split()[0] if bind_line else ""
                   if bind_token != bindStr:
   ```



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