Unverified Commit def5179c authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #64739 from feiskyer/az-nsg

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix panic while provisioning Azure security group rules **What this PR does / why we need it**: kube-controller-manager panic when provisioning Azure security group rules, especially when securityGroupName is wrong configured. This PR fixes the issue. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #64716 **Special notes for your reviewer**: Should also cherry pick to release-1.10. **Release note**: ```release-note Fix kube-controller-manager panic while provisioning Azure security group rules ```
parents 0f9dfca8 8f52d823
...@@ -926,8 +926,8 @@ func (az *Cloud) reconcileSecurityGroup(clusterName string, service *v1.Service, ...@@ -926,8 +926,8 @@ func (az *Cloud) reconcileSecurityGroup(clusterName string, service *v1.Service,
// update security rules // update security rules
dirtySg := false dirtySg := false
var updatedRules []network.SecurityRule var updatedRules []network.SecurityRule
if sg.SecurityRules != nil { if sg.SecurityGroupPropertiesFormat != nil && sg.SecurityGroupPropertiesFormat.SecurityRules != nil {
updatedRules = *sg.SecurityRules updatedRules = *sg.SecurityGroupPropertiesFormat.SecurityRules
} }
for _, r := range updatedRules { for _, r := range updatedRules {
......
...@@ -163,6 +163,10 @@ func (az *Cloud) getAzureLoadBalancer(name string) (lb network.LoadBalancer, exi ...@@ -163,6 +163,10 @@ func (az *Cloud) getAzureLoadBalancer(name string) (lb network.LoadBalancer, exi
} }
func (az *Cloud) getSecurityGroup() (nsg network.SecurityGroup, err error) { func (az *Cloud) getSecurityGroup() (nsg network.SecurityGroup, err error) {
if az.SecurityGroupName == "" {
return nsg, fmt.Errorf("securityGroupName is not configured")
}
securityGroup, err := az.nsgCache.Get(az.SecurityGroupName) securityGroup, err := az.nsgCache.Get(az.SecurityGroupName)
if err != nil { if err != nil {
return nsg, err return nsg, err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment