soreana commented on a change in pull request #4141:
URL: https://github.com/apache/cloudstack/pull/4141#discussion_r670468405
##########
File path: core/src/main/java/com/cloud/network/HAProxyConfigurator.java
##########
@@ -531,42 +654,111 @@ private String getLbSubRuleForStickiness(final
LoadBalancerTO lbTO) {
}
}
if (httpbasedStickiness) {
- result.addAll(dstWithCookieSubRule);
+ backendConfigs.addAll(dstWithCookieSubRule);
} else {
- result.addAll(dstSubRule);
+ backendConfigs.addAll(dstSubRule);
}
- result.add(stickinessSubRule);
+ backendConfigs.add(stickinessSubRule);
} else {
- result.addAll(dstSubRule);
+ backendConfigs.addAll(dstSubRule);
}
if (stickinessSubRule != null && !destsAvailable) {
s_logger.warn("Haproxy stickiness policy for lb rule: " +
lbTO.getSrcIp() + ":" + lbTO.getSrcPort() + ": Not Applied, cause: backends
are unavailable");
}
- if (publicPort == NetUtils.HTTP_PORT && !keepAliveEnabled ||
httpbasedStickiness) {
+ boolean http = false;
+ String cfgLbHttp =
lbConfigsMap.get(LoadBalancerConfigKey.LbHttp.key());
+ if (publicPort == NetUtils.HTTP_PORT && cfgLbHttp == null) {
+ http = true;
+ } else if (cfgLbHttp != null && cfgLbHttp.equalsIgnoreCase("true")) {
+ http = true;
+ }
+
+ boolean keepAliveEnabled = lbCmd.keepAliveEnabled;
+ String cfgLbHttpKeepalive =
lbConfigsMap.get(LoadBalancerConfigKey.LbHttpKeepalive.key());
+ if (cfgLbHttpKeepalive != null &&
cfgLbHttpKeepalive.equalsIgnoreCase("true")) {
+ keepAliveEnabled = true;
+ } else if (cfgLbHttpKeepalive != null &&
cfgLbHttpKeepalive.equalsIgnoreCase("false")) {
+ keepAliveEnabled = false;
+ }
+
+ if (http || httpbasedStickiness || sslOffloading) {
sb = new StringBuilder();
sb.append("\t").append("mode http");
+ frontendConfigs.add(sb.toString());
+ backendConfigsForHttp.add(sb.toString());
+ if (keepAliveEnabled) {
+ sb = new StringBuilder();
+ sb.append("\t").append("no option forceclose");
+ frontendConfigs.add(sb.toString());
+ backendConfigsForHttp.add(sb.toString());
+ } else {
+ sb = new StringBuilder();
+ sb.append("\t").append("option httpclose");
+ frontendConfigs.add(sb.toString());
+ backendConfigsForHttp.add(sb.toString());
+ }
+ }
+
+ if (isTransparent) {
+ sb = new StringBuilder();
+ sb.append("frontend ").append(poolName);
result.add(sb.toString());
+ result.addAll(frontendConfigs);
sb = new StringBuilder();
- sb.append("\t").append("option httpclose");
+ sb.append("\tacl local_subnet src
").append(lbCmd.getNetworkCidr());
+ sb.append("\n\tuse_backend
").append(poolName).append("-backend-local if local_subnet");
+ sb.append("\n\tdefault_backend
").append(poolName).append("-backend");
+ sb.append("\n\n");
+ sb.append("backend ").append(poolName).append("-backend");
+ result.add(sb.toString());
+ result.addAll(backendConfigsForHttp);
+ result.addAll(backendConfigs);
+ sb = new StringBuilder();
+ sb.append("\t").append("source 0.0.0.0 usesrc clientip");
+ sb.append("\n\n");
Review comment:
@GutoVeronezi For line 707 ... 713, it is better to leave it as it is.
It would be a long String.format expression and hard to read. I changed the
remaining.
--
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]