Skip to content

Commit 0fa0320

Browse files
CLOUDSTACK-7418 and CLOUDSTACK-7488 - Fixed LB removal if cert is associated
2 parents cacbc80 + 18653f6 commit 0fa0320

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,15 @@ public boolean deleteLoadBalancerRule(final long loadBalancerId, boolean apply,
14781478
final LoadBalancerVO lb = _lbDao.findById(loadBalancerId);
14791479
FirewallRule.State backupState = lb.getState();
14801480

1481+
// remove any ssl certs associated with this LB rule before trying to delete it.
1482+
LoadBalancerCertMapVO lbCertMap = _lbCertMapDao.findByLbRuleId(loadBalancerId);
1483+
if (lbCertMap != null) {
1484+
boolean removeResult = removeCertFromLoadBalancer(loadBalancerId);
1485+
if (!removeResult) {
1486+
throw new CloudRuntimeException("Unable to remove certificate from load balancer rule " + loadBalancerId);
1487+
}
1488+
}
1489+
14811490
List<LoadBalancerVMMapVO> backupMaps = Transaction.execute(new TransactionCallback<List<LoadBalancerVMMapVO>>() {
14821491
@Override
14831492
public List<LoadBalancerVMMapVO> doInTransaction(TransactionStatus status) {

‎server/src/org/apache/cloudstack/network/lb/CertServiceImpl.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,9 @@ public SslCertResponse createCertResponse(SslCertVO cert, List<LoadBalancerCertM
325325
List<String> lbIds = new ArrayList<String>();
326326
for (LoadBalancerCertMapVO mapVO : lbCertMap) {
327327
LoadBalancer lb = _entityMgr.findById(LoadBalancerVO.class, mapVO.getLbId());
328-
lbIds.add(lb.getUuid());
328+
if (lb != null) {
329+
lbIds.add(lb.getUuid());
330+
}
329331
}
330332
response.setLbIds(lbIds);
331333
}

0 commit comments

Comments
 (0)