mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #49805 from nbutton23/nbutton-fix-elb-sg-bug
Automatic merge from submit-queue (batch tested with PRs 49805, 50052) We never want to modify the globally defined SG for ELBs **What this PR does / why we need it**: Fixes a bug where creating or updating an ELB will modify a globally defined security group **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #50105 **Special notes for your reviewer**: **Release note**: ```release-note fixes a bug around using the Global config ElbSecurityGroup where Kuberentes would modify the passed in Security Group. ```
This commit is contained in:
commit
207a95a076
@ -2101,6 +2101,11 @@ func isEqualUserGroupPair(l, r *ec2.UserIdGroupPair, compareGroupUserIDs bool) b
|
|||||||
// Returns true if and only if changes were made
|
// Returns true if and only if changes were made
|
||||||
// The security group must already exist
|
// The security group must already exist
|
||||||
func (c *Cloud) setSecurityGroupIngress(securityGroupID string, permissions IPPermissionSet) (bool, error) {
|
func (c *Cloud) setSecurityGroupIngress(securityGroupID string, permissions IPPermissionSet) (bool, error) {
|
||||||
|
// We do not want to make changes to the Global defined SG
|
||||||
|
if securityGroupID == c.cfg.Global.ElbSecurityGroup {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
group, err := c.findSecurityGroup(securityGroupID)
|
group, err := c.findSecurityGroup(securityGroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error retrieving security group %q", err)
|
glog.Warningf("Error retrieving security group %q", err)
|
||||||
@ -2171,6 +2176,11 @@ func (c *Cloud) setSecurityGroupIngress(securityGroupID string, permissions IPPe
|
|||||||
// Returns true if and only if changes were made
|
// Returns true if and only if changes were made
|
||||||
// The security group must already exist
|
// The security group must already exist
|
||||||
func (c *Cloud) addSecurityGroupIngress(securityGroupID string, addPermissions []*ec2.IpPermission) (bool, error) {
|
func (c *Cloud) addSecurityGroupIngress(securityGroupID string, addPermissions []*ec2.IpPermission) (bool, error) {
|
||||||
|
// We do not want to make changes to the Global defined SG
|
||||||
|
if securityGroupID == c.cfg.Global.ElbSecurityGroup {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
group, err := c.findSecurityGroup(securityGroupID)
|
group, err := c.findSecurityGroup(securityGroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error retrieving security group: %q", err)
|
glog.Warningf("Error retrieving security group: %q", err)
|
||||||
@ -2227,6 +2237,11 @@ func (c *Cloud) addSecurityGroupIngress(securityGroupID string, addPermissions [
|
|||||||
// Returns true if and only if changes were made
|
// Returns true if and only if changes were made
|
||||||
// If the security group no longer exists, will return (false, nil)
|
// If the security group no longer exists, will return (false, nil)
|
||||||
func (c *Cloud) removeSecurityGroupIngress(securityGroupID string, removePermissions []*ec2.IpPermission) (bool, error) {
|
func (c *Cloud) removeSecurityGroupIngress(securityGroupID string, removePermissions []*ec2.IpPermission) (bool, error) {
|
||||||
|
// We do not want to make changes to the Global defined SG
|
||||||
|
if securityGroupID == c.cfg.Global.ElbSecurityGroup {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
group, err := c.findSecurityGroup(securityGroupID)
|
group, err := c.findSecurityGroup(securityGroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error retrieving security group: %q", err)
|
glog.Warningf("Error retrieving security group: %q", err)
|
||||||
@ -2554,7 +2569,7 @@ func getPortSets(annotation string) (ports *portSets) {
|
|||||||
|
|
||||||
// buildELBSecurityGroupList returns list of SecurityGroups which should be
|
// buildELBSecurityGroupList returns list of SecurityGroups which should be
|
||||||
// attached to ELB created by a service. List always consist of at least
|
// attached to ELB created by a service. List always consist of at least
|
||||||
// 1 member which is an SG created for this service. Extra groups can be
|
// 1 member which is an SG created for this service or a SG from the Global config. Extra groups can be
|
||||||
// specified via annotation
|
// specified via annotation
|
||||||
func (c *Cloud) buildELBSecurityGroupList(serviceName types.NamespacedName, loadBalancerName, annotation string) ([]string, error) {
|
func (c *Cloud) buildELBSecurityGroupList(serviceName types.NamespacedName, loadBalancerName, annotation string) ([]string, error) {
|
||||||
var err error
|
var err error
|
||||||
|
Loading…
Reference in New Issue
Block a user