Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit 8689b39

Browse files
committed
Remove getOldSecurityGroupName() from OpenStack cloud provider
Related to #53764 The getOldSecurityGroupName() is used to get the old security group name, we can remove it now.
1 parent 588431e commit 8689b39

1 file changed

Lines changed: 0 additions & 79 deletions

File tree

pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -959,14 +959,6 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(clusterName string, apiService *v1.Serv
959959
_ = lbaas.EnsureLoadBalancerDeleted(clusterName, apiService)
960960
return status, err
961961
}
962-
963-
// delete the old Security Group for the service
964-
// Related to #53764
965-
// TODO(FengyunPan): Remove it at V1.10
966-
err = lbaas.EnsureOldSecurityGroupDeleted(clusterName, apiService)
967-
if err != nil {
968-
return status, fmt.Errorf("Failed to delete the Security Group for loadbalancer service %s/%s: %v", apiService.Namespace, apiService.Name, err)
969-
}
970962
}
971963

972964
return status, nil
@@ -1492,14 +1484,6 @@ func (lbaas *LbaasV2) EnsureLoadBalancerDeleted(clusterName string, service *v1.
14921484
if err != nil {
14931485
return fmt.Errorf("Failed to delete Security Group for loadbalancer service %s/%s: %v", service.Namespace, service.Name, err)
14941486
}
1495-
1496-
// delete the old Security Group for the service
1497-
// Related to #53764
1498-
// TODO(FengyunPan): Remove it at V1.10
1499-
err = lbaas.EnsureOldSecurityGroupDeleted(clusterName, service)
1500-
if err != nil {
1501-
return fmt.Errorf("Failed to delete the Security Group for loadbalancer service %s/%s: %v", service.Namespace, service.Name, err)
1502-
}
15031487
}
15041488

15051489
return nil
@@ -1557,66 +1541,3 @@ func (lbaas *LbaasV2) EnsureSecurityGroupDeleted(clusterName string, service *v1
15571541

15581542
return nil
15591543
}
1560-
1561-
// getOldSecurityGroupName is used to get the old security group name
1562-
// Related to #53764
1563-
// TODO(FengyunPan): Remove it at V1.10
1564-
func getOldSecurityGroupName(clusterName string, service *v1.Service) string {
1565-
return fmt.Sprintf("lb-sg-%s-%v", clusterName, service.Name)
1566-
}
1567-
1568-
// EnsureOldSecurityGroupDeleted deleting old security group for specific loadbalancer service.
1569-
// Related to #53764
1570-
// TODO(FengyunPan): Remove it at V1.10
1571-
func (lbaas *LbaasV2) EnsureOldSecurityGroupDeleted(clusterName string, service *v1.Service) error {
1572-
glog.V(4).Infof("EnsureOldSecurityGroupDeleted(%v, %v)", clusterName, service)
1573-
// Generate Name
1574-
lbSecGroupName := getOldSecurityGroupName(clusterName, service)
1575-
lbSecGroupID, err := groups.IDFromName(lbaas.network, lbSecGroupName)
1576-
if err != nil {
1577-
// check whether security group does not exist
1578-
_, ok := err.(*gophercloud.ErrResourceNotFound)
1579-
if ok {
1580-
// It is OK when the security group has been deleted by others.
1581-
return nil
1582-
} else {
1583-
return fmt.Errorf("Error occurred finding security group: %s: %v", lbSecGroupName, err)
1584-
}
1585-
}
1586-
1587-
lbSecGroup := groups.Delete(lbaas.network, lbSecGroupID)
1588-
if lbSecGroup.Err != nil && !isNotFound(lbSecGroup.Err) {
1589-
return lbSecGroup.Err
1590-
}
1591-
1592-
if len(lbaas.opts.NodeSecurityGroupIDs) == 0 {
1593-
// Just happen when nodes have not Security Group, or should not happen
1594-
// UpdateLoadBalancer and EnsureLoadBalancer can set lbaas.opts.NodeSecurityGroupIDs when it is empty
1595-
// And service controller call UpdateLoadBalancer to set lbaas.opts.NodeSecurityGroupIDs when controller manager service is restarted.
1596-
glog.Warningf("Can not find node-security-group from all the nodes of this cluster when delete loadbalancer service %s/%s",
1597-
service.Namespace, service.Name)
1598-
} else {
1599-
// Delete the rules in the Node Security Group
1600-
for _, nodeSecurityGroupID := range lbaas.opts.NodeSecurityGroupIDs {
1601-
opts := rules.ListOpts{
1602-
SecGroupID: nodeSecurityGroupID,
1603-
RemoteGroupID: lbSecGroupID,
1604-
}
1605-
secGroupRules, err := getSecurityGroupRules(lbaas.network, opts)
1606-
1607-
if err != nil && !isNotFound(err) {
1608-
msg := fmt.Sprintf("Error finding rules for remote group id %s in security group id %s: %v", lbSecGroupID, nodeSecurityGroupID, err)
1609-
return fmt.Errorf(msg)
1610-
}
1611-
1612-
for _, rule := range secGroupRules {
1613-
res := rules.Delete(lbaas.network, rule.ID)
1614-
if res.Err != nil && !isNotFound(res.Err) {
1615-
return fmt.Errorf("Error occurred deleting security group rule: %s: %v", rule.ID, res.Err)
1616-
}
1617-
}
1618-
}
1619-
}
1620-
1621-
return nil
1622-
}

0 commit comments

Comments
 (0)