Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New feature] Load balancer customization (haproxy-based) #4141

Closed
wants to merge 83 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
539ff56
LB configs: Load Balancer customization
ustcweizhou May 18, 2020
8832d25
UI: Remove duplicated tabs for VPC routers
ustcweizhou May 19, 2020
2f4d613
LB configs: Customized LB config on VPC
ustcweizhou May 19, 2020
23cd6fd
Add Network/Vpc config: haproxy.stats.enable
ustcweizhou May 19, 2020
f1ab741
Support multiple scopes in LoadBalancerConfigKey
ustcweizhou May 24, 2020
c435afe
Move networkLbConfigsMap into method
ustcweizhou May 24, 2020
9383261
LB configs: List all LB configs by scope (listall must be true)
ustcweizhou May 24, 2020
d19076e
LB configs: Add timeout for global/lb
ustcweizhou May 26, 2020
67b43db
LB configs: Add loadbalancer connections settings
May 28, 2020
af6ab20
LB configs: customized load balancer configuration for lb http/keepalive
May 27, 2020
4a35ee2
Fix build error
ravening May 28, 2020
c759f69
Set keepAliveEnabled to false if lb.http.keepalive is false
ustcweizhou May 28, 2020
ffa0a9a
VR: compare list instead of set in CsFile.py
ustcweizhou May 28, 2020
7c4da09
LB configs: Add haproxy stats
May 28, 2020
bfa64da
Use Optional.ofNullable instead of Optional.of to fix NPE
ustcweizhou May 28, 2020
3d0e012
Rename timeout to lb.timeout
ustcweizhou May 29, 2020
240acfc
Fix haproxy config is not change when remove timeout
ustcweizhou May 29, 2020
7bff801
LB configs: Set default value in haproxy for lb configs
ustcweizhou Jun 3, 2020
5e3f152
LB configs: Add 'mode http' to http LBs
ustcweizhou Jun 3, 2020
8f9f752
Add 'no option forceclose' to http keep-alive rules
ustcweizhou Jun 4, 2020
757be26
LB configs: Enable/disable haproxy socket
ustcweizhou Jun 5, 2020
9c6fa85
LB: remove console.log from ui
ustcweizhou Jun 8, 2020
7a1a2a9
Create table load_balancer_config in schema-41400to41500.sql
ustcweizhou Jun 10, 2020
0df8cc7
LB transparent mode
ustcweizhou Jun 10, 2020
f52a609
LB: generate separated list for frontend and backend
ustcweizhou Jun 10, 2020
ea66b36
LB transparent mode: use different backend for local network
ustcweizhou Jun 10, 2020
e44c8f6
LB transparent mode: remove from network config
ustcweizhou Jun 17, 2020
f50330c
Lb transparent: fix test failures in core/
ustcweizhou Jun 17, 2020
156c4f4
LB SSL offloading
ustcweizhou Jun 17, 2020
1e7dd8f
Lb SSL offloading: fix test failures in core/
ustcweizhou Jun 18, 2020
68036f7
CLSTACK-6898 - Enable HTTP2 support in LB
Jun 18, 2020
ece2b9b
UI for SSL offloading
ustcweizhou Jun 19, 2020
30052e4
LB SSL offloading: Fix issue when remove cert from lb
ustcweizhou Jun 19, 2020
78eabc1
add forced to AssignCertToLoadBalancerCmd
ustcweizhou Jun 19, 2020
1584234
Update LB protocol
ustcweizhou Jun 20, 2020
81125fc
UI: add 'none' to dropdown so that remove lb certificate
ustcweizhou Jun 22, 2020
3e089fe
LB: Add lb.backend.https (it will use 'check ssl verify none' instead…
ustcweizhou Jun 22, 2020
fdb416e
LB SSL offloading: (1) move certs to /etc/ssl/cloudstack; (2)UI bug f…
ustcweizhou Jun 24, 2020
2bd2c56
LB SSL Offloading: create global constant SSL_CERTS_DIR, add tune.ssl…
ustcweizhou Jun 26, 2020
23fdf4b
health check for LB configs
ustcweizhou Jun 23, 2020
d6c1251
haproxy check: global and defaults
ustcweizhou Jun 24, 2020
9f34384
move /etc/ssl/private/ to /etc/ssl/cloudstack/
ustcweizhou Jun 25, 2020
d7c48f4
LB haproxy check: fix check failure after VR restart
ustcweizhou Jul 1, 2020
edd8e0e
CLSTACK-7838 - Fix haproxy configs for servers
Jul 1, 2020
efcbcbf
Code refactor
Jul 1, 2020
61ba911
add lb rule checks
Jul 3, 2020
a3bbacb
add frontend/backend checks
Jul 6, 2020
ee75cab
haproxy check: set sslcert only if lb protocol is 'ssl'
ustcweizhou Jul 8, 2020
e205c22
haproxy check: http2 is enabled only if ssl offloading is enabled
ustcweizhou Jul 8, 2020
95f5695
haproxy check: 'mode http' is enabled in some conditions
ustcweizhou Jul 8, 2020
4f92d50
Add configuration for ssl customization.
Jul 6, 2020
dfc6cce
Port changes from 4.7.1.
Jul 6, 2020
76b78ac
Move old and intermediate configuration to HAProxy frontend.
Jul 10, 2020
4f0b35d
Fixed missed ssl restriction of haproxy.
Jul 10, 2020
fc623c1
Added Global setting configuration.
Jul 13, 2020
3a58185
Move global setting from api to engine/components-api
ustcweizhou Jul 13, 2020
9a6e8d4
fix haproxy check
ustcweizhou Jul 14, 2020
6237ba2
Add enum LoadBalancerConfig.SSLConfiguration
ustcweizhou Jul 14, 2020
668a189
fix pycodestyle failures with CsLoadBalancer.py and haproxy_check.py
ustcweizhou Jul 21, 2020
f98e575
lb config: fix NPE with test_loadbalance.py
ustcweizhou Aug 13, 2020
c9e4b70
Move some files from com.cloud to org.apache.cloudstack
ustcweizhou Sep 23, 2020
d7b51ec
LB config: set uuid instead of id in response
ustcweizhou May 20, 2020
95c1a9b
LB config: add method validateParameters
ustcweizhou Jun 18, 2020
3d7bcda
Merge remote-tracking branch 'apache/master' into 4.15-lbconfigs
ustcweizhou Nov 9, 2020
26ccc8e
#4141: Support config list like "config[0].global.maxconn=XXX"
ustcweizhou Nov 10, 2020
454b660
#4141 LB config: Fix spring-server-core-managers-context.xml
ustcweizhou Sep 28, 2020
1ccff82
#4141: return empty list if config is null
ustcweizhou Nov 11, 2020
9d303ed
#4141 Ignore case for protocol name in LB rules
Nov 23, 2020
b3d4e72
Merge remote-tracking branch 'apache/master' into 4.15-lbconfigs
ustcweizhou Jan 14, 2021
6e2e86b
#4141 LB config: fix many 'mkdir -p /etc/ssl/cloudstack/' in /var/lo…
ustcweizhou Jan 4, 2021
c1c07a9
Merge remote-tracking branch 'apache/master' into 4.15-lbconfigs
ustcweizhou Jan 27, 2021
9f1860c
LB config: String values should not contain whitespace
ustcweizhou Jan 20, 2021
39e7def
LB: verify haproxy config before haproxy restart/reload
ustcweizhou Jan 20, 2021
24c1206
Load balancer configurations using HAProxy
ravening Jan 26, 2021
2f07a1f
LB: fix pylint check failure
ustcweizhou Feb 17, 2021
5690847
LB: fix ui npm lint error
ustcweizhou Mar 8, 2021
b59b4b8
Merge remote-tracking branch 'apache/master' into 4.15-lbconfigs
ustcweizhou Mar 15, 2021
fd8e6b2
LB config: move sql to schema-41510to41600.sql
ustcweizhou Mar 15, 2021
0009b8d
Merge remote-tracking branch 'apache/master' into 4.15-lbconfigs
ustcweizhou Apr 23, 2021
4125854
Merge remote-tracking branch 'apache/main' into 4.15-lbconfigs
weizhouapache Jun 29, 2021
444d37a
Merge branch 'main' of https://github.com/apache/cloudstack into apac…
Jul 12, 2021
317ecbb
Merge branch 'apache-main' into 4.15-lbconfigs
Jul 12, 2021
f5e5d0c
Refactored the code, regarding the code change suggetions by GutoVero…
Jul 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 42 additions & 0 deletions api/src/main/java/com/cloud/agent/api/to/LoadBalancerConfigTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.api.to;

import org.apache.cloudstack.network.lb.LoadBalancerConfig;

public class LoadBalancerConfigTO {
private String name;
private String value;

public LoadBalancerConfigTO(String name, String value) {
this.name = name;
this.value = value;
}

public LoadBalancerConfigTO(LoadBalancerConfig config) {
this.name = config.getName();
this.value = config.getValue();
}

public String getName() {
return name;
}

public String getValue() {
return value;
}
}
24 changes: 24 additions & 0 deletions api/src/main/java/com/cloud/agent/api/to/LoadBalancerTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
import com.cloud.utils.Pair;

import org.apache.cloudstack.network.lb.LoadBalancerConfig;
import org.springframework.util.CollectionUtils;

public class LoadBalancerTO {
String uuid;
String srcIp;
Expand All @@ -50,6 +53,7 @@ public class LoadBalancerTO {
String srcIpNetmask;
Long networkId;
DestinationTO[] destinations;
private LoadBalancerConfigTO[] lbConfigs;
private StickinessPolicyTO[] stickinessPolicies;
private HealthCheckPolicyTO[] healthCheckPolicies;
private LbSslCert sslCert; /* XXX: Should this be SslCertTO? */
Expand Down Expand Up @@ -179,6 +183,22 @@ public boolean isInline() {
return inline;
}

public LoadBalancerConfigTO[] getLbConfigs() {
return this.lbConfigs;
}

public void setLbConfigs(List<? extends LoadBalancerConfig> lbConfigs) {
if (CollectionUtils.isEmpty(lbConfigs)) {
this.lbConfigs = new LoadBalancerConfigTO[0];
return;
}
this.lbConfigs = new LoadBalancerConfigTO[lbConfigs.size()];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weizhouapache advised changes to improve similar code, consider this as well. thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sureshanaparti this has been changed in commit as well
1ccff82

int i = 0;
for (LoadBalancerConfig lbConfig : lbConfigs) {
this.lbConfigs[i++] = new LoadBalancerConfigTO(lbConfig);
}
}

public StickinessPolicyTO[] getStickinessPolicies() {
return stickinessPolicies;
}
Expand Down Expand Up @@ -207,6 +227,10 @@ public LbSslCert getSslCert() {
return this.sslCert;
}

public void setLbSslCert(LbSslCert sslCert) {
this.sslCert = sslCert;
}

public String getSrcIpVlan() {
return srcIpVlan;
}
Expand Down
4 changes: 4 additions & 0 deletions api/src/main/java/com/cloud/event/EventTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ public class EventTypes {
public static final String EVENT_LB_CERT_DELETE = "LB.CERT.DELETE";
public static final String EVENT_LB_CERT_ASSIGN = "LB.CERT.ASSIGN";
public static final String EVENT_LB_CERT_REMOVE = "LB.CERT.REMOVE";
public static final String EVENT_LOAD_BALANCER_CONFIG_CREATE = "LB.CONFIG.CREATE";
public static final String EVENT_LOAD_BALANCER_CONFIG_DELETE = "LB.CONFIG.DELETE";
public static final String EVENT_LOAD_BALANCER_CONFIG_REPLACE = "LB.CONFIG.REPLACE";
public static final String EVENT_LOAD_BALANCER_CONFIG_UPDATE = "LB.CONFIG.UPDATE";

// Global Load Balancer rules
public static final String EVENT_ASSIGN_TO_GLOBAL_LOAD_BALANCER_RULE = "GLOBAL.LB.ASSIGN";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ LoadBalancer createPublicLoadBalancerRule(String xId, String name, String descri

boolean applyLoadBalancerConfig(long lbRuleId) throws ResourceUnavailableException;

boolean assignCertToLoadBalancer(long lbRuleId, Long certId);
boolean assignCertToLoadBalancer(long lbRuleId, Long certId, boolean forced);

boolean removeCertFromLoadBalancer(long lbRuleId);

Expand Down
3 changes: 3 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public class ApiConstants {
public static final String CLUSTER_TYPE = "clustertype";
public static final String CN = "cn";
public static final String COMMAND = "command";
public static final String CONFIG = "config";
public static final String CMD_EVENT_TYPE = "cmdeventtype";
public static final String COMPONENT = "component";
public static final String CPU_CORE_PER_SOCKET = "cpucorepersocket";
Expand All @@ -100,6 +101,7 @@ public class ApiConstants {
public static final String MAX_IOPS = "maxiops";
public static final String HYPERVISOR_SNAPSHOT_RESERVE = "hypervisorsnapshotreserve";
public static final String DATADISK_OFFERING_LIST = "datadiskofferinglist";
public static final String DEFAULT_VALUE = "defaultvalue";
public static final String DESCRIPTION = "description";
public static final String DESTINATION_ZONE_ID = "destzoneid";
public static final String DETAILS = "details";
Expand Down Expand Up @@ -541,6 +543,7 @@ public class ApiConstants {
public static final String LOAD_BALANCER_DEVICE_STATE = "lbdevicestate";
public static final String LOAD_BALANCER_DEVICE_CAPACITY = "lbdevicecapacity";
public static final String LOAD_BALANCER_DEVICE_DEDICATED = "lbdevicededicated";
public static final String LOAD_BALANCER_ID = "loadbalancerid";
public static final String LOAD_BALANCER_RULE = "loadbalancerrule";
public static final String LOAD_BALANCER_RULE_LIST = "loadbalancerrulelist";
public static final String FIREWALL_DEVICE_ID = "fwdeviceid";
Expand Down
3 changes: 3 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/BaseCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService;
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
import org.apache.cloudstack.network.lb.LoadBalancerConfigService;
import org.apache.cloudstack.query.QueryService;
import org.apache.cloudstack.storage.ImageStoreService;
import org.apache.cloudstack.usage.UsageService;
Expand Down Expand Up @@ -150,6 +151,8 @@ public static enum CommandType {
@Inject
public LoadBalancingRulesService _lbService;
@Inject
public LoadBalancerConfigService _lbConfigService;
@Inject
public RemoteAccessVpnService _ravService;
@Inject
public ProjectService _projectService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
import org.apache.cloudstack.api.response.LBStickinessResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.LoadBalancerConfigResponse;
import org.apache.cloudstack.api.response.LoadBalancerResponse;
import org.apache.cloudstack.api.response.ManagementServerResponse;
import org.apache.cloudstack.api.response.NetworkACLItemResponse;
Expand Down Expand Up @@ -129,6 +130,7 @@
import org.apache.cloudstack.backup.BackupSchedule;
import org.apache.cloudstack.config.Configuration;
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
import org.apache.cloudstack.network.lb.LoadBalancerConfig;
import org.apache.cloudstack.region.PortableIp;
import org.apache.cloudstack.region.PortableIpRange;
import org.apache.cloudstack.region.Region;
Expand Down Expand Up @@ -260,6 +262,10 @@ public interface ResponseGenerator {

LoadBalancerResponse createLoadBalancerResponse(LoadBalancer loadBalancer);

LoadBalancerConfigResponse createLoadBalancerConfigResponse(LoadBalancerConfig config);

List<LoadBalancerConfigResponse> createLoadBalancerConfigResponse(List<? extends LoadBalancerConfig> configs);

LBStickinessResponse createLBStickinessPolicyResponse(List<? extends StickinessPolicy> stickinessPolicies, LoadBalancer lb);

LBStickinessResponse createLBStickinessPolicyResponse(StickinessPolicy stickinessPolicy, LoadBalancer lb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
// under the License.
package org.apache.cloudstack.api.command.user.loadbalancer;

import org.apache.commons.lang3.BooleanUtils;
import org.apache.log4j.Logger;

import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
Expand Down Expand Up @@ -60,11 +62,17 @@ public class AssignCertToLoadBalancerCmd extends BaseAsyncCmd {
description = "the ID of the certificate")
Long certId;

@Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false,
since = "4.15",
description = "Force assign the certificate. If there is a certificate bound to the LB, it will be removed")
private Boolean forced;


@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException, NetworkRuleConflictException {
//To change body of implemented methods use File | Settings | File Templates.
if (_lbService.assignCertToLoadBalancer(getLbRuleId(), getCertId())) {
if (_lbService.assignCertToLoadBalancer(getLbRuleId(), getCertId(), isForced())) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
Expand Down Expand Up @@ -103,4 +111,29 @@ public Long getCertId() {
public Long getLbRuleId() {
return lbRuleId;
}

public boolean isForced() {
return BooleanUtils.toBoolean(forced);
}

@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.LoadBalancerRule;
}

@Override
public Long getInstanceId() {
return lbRuleId;
}

@Override
public String getSyncObjType() {
return BaseAsyncCmd.networkSyncObject;
}

@Override
public Long getSyncObjId() {
LoadBalancer lb = _entityMgr.findById(LoadBalancer.class, getLbRuleId());
return (lb != null )? lb.getNetworkId(): null;
}
}