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

Fix a loop pointer bug in EnsureBackendPoolDeleted #3417

Merged

Conversation

lzhecheng
Copy link
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

Fix a loop pointer bug in EnsureBackendPoolDeleted

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Fix nic CreateOrUpdate bug when there are more than one nic.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Feb 28, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lzhecheng

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 28, 2023
@netlify
Copy link

netlify bot commented Feb 28, 2023

Deploy Preview for kubernetes-sigs-cloud-provide-azure canceled.

Name Link
🔨 Latest commit e0f918c
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cloud-provide-azure/deploys/63fddea512652e00082019e3

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 28, 2023
@lzhecheng
Copy link
Contributor Author

lzhecheng commented Feb 28, 2023

Without this fix, there'll be ccm log like:

I0217 16:34:57.669834       1 azure_standard.go:1170] EnsureBackendPoolDeleted begins to CreateOrUpdate for NIC(capz-1lmk86, capz-1lmk86-md-0-jskfk-nic) with backendPoolIDs ["/subscriptions/===REDACTED===/resourceGroups/capz-1lmk86/providers/Microsoft.Network/loadBalancers/capz-1lmk86-internal/backendAddressPools/capz-1lmk86"]
I0217 16:34:57.670237       1 azure_standard.go:1170] EnsureBackendPoolDeleted begins to CreateOrUpdate for NIC(capz-1lmk86, capz-1lmk86-md-0-jskfk-nic) with backendPoolIDs ["/subscriptions/===REDACTED===/resourceGroups/capz-1lmk86/providers/Microsoft.Network/loadBalancers/capz-1lmk86-internal/backendAddressPools/capz-1lmk86"]
I0217 16:35:02.380778       1 route_controller.go:299] set node capz-1lmk86-md-0-hv6xj with NodeNetworkUnavailable=false was canceled because it is already set
I0217 16:35:02.380790       1 route_controller.go:299] set node capz-1lmk86-control-plane-mtgjt with NodeNetworkUnavailable=false was canceled because it is already set
I0217 16:35:02.380804       1 route_controller.go:299] set node capz-1lmk86-md-0-jskfk with NodeNetworkUnavailable=false was canceled because it is already set
I0217 16:35:06.334583       1 reflector.go:281] k8s.io/client-go/informers/factory.go:150: forcing resync
I0217 16:35:06.355673       1 reflector.go:281] k8s.io/client-go/informers/factory.go:150: forcing resync
I0217 16:35:06.558611       1 httplog.go:132] "HTTP" verb="GET" URI="/healthz" latency="87.801µs" userAgent="kube-probe/1.27+" audit-ID="" srcIP="10.0.0.4:59628" resp=200
E0217 16:35:08.368708       1 azure_standard.go:1173] EnsureBackendPoolDeleted CreateOrUpdate for NIC(capz-1lmk86, capz-1lmk86-md-0-jskfk-nic) failed with error Retriable: false, RetryAfter: 0s, HTTPStatusCode: 412, RawError: {
  "error": {
    "code": "PreconditionFailed",
    "message": "Precondition failed.",
    "details": [
      {
        "code": "PreconditionFailedEtagMismatch",
        "message": "Etag provided in if-match header W/\"3da7bfdc-ed3f-47f4-a5dd-593e7bf4bcc2\" does not match etag W/\"c2106c0a-80d7-4459-814d-1e3832912d27\" of resource /subscriptions/===REDACTED===/resourceGroups/capz-1lmk86/providers/Microsoft.Network/networkInterfaces/capz-1lmk86-md-0-jskfk-nic in NRP data store."
      }
    ]
  }
}](https://storage.googleapis.com/kubernetes-jenkins/logs/cloud-provider-azure-master-capz/1626612592988393472/artifacts/clusters/capz-1lmk86/kube-system/cloud-controller-manager-7b484f44c5-jndnt/cloud-controller-manager.log)

https://storage.googleapis.com/kubernetes-jenkins/logs/cloud-provider-azure-master-capz/1626612592988393472/artifacts/clusters/capz-1lmk86/kube-system/cloud-controller-manager-7b484f44c5-jndnt/cloud-controller-manager.log

@coveralls
Copy link

Coverage Status

Coverage: 79.526% (-0.008%) from 79.534% when pulling e0f918c on lzhecheng:fix-bp-loop-pointer-bug into 3d4f5cd on kubernetes-sigs:master.

@jwtty
Copy link
Member

jwtty commented Feb 28, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2023
@@ -1142,7 +1142,8 @@ func (as *availabilitySet) EnsureBackendPoolDeleted(service *v1.Service, backend
ipconfigPrefixToNicMap[ipConfigIDPrefix] = nic
}
}
for _, nic := range ipconfigPrefixToNicMap {
for k := range ipconfigPrefixToNicMap {
Copy link
Member

@feiskyer feiskyer Feb 28, 2023

Choose a reason for hiding this comment

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

Good catch. Are there any golint rules could be enabled to catch such issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should have it: golangci-lint but somehow it isn't working here. I'll investigate how to solve it.

Copy link
Member

Choose a reason for hiding this comment

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

that's a classic pointer bug in go range statement, it's interesting how to catch it by some scanning tool.

@lzhecheng
Copy link
Contributor Author

/retest

1 similar comment
@lzhecheng
Copy link
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit f927b5e into kubernetes-sigs:master Mar 1, 2023
@lzhecheng lzhecheng deleted the fix-bp-loop-pointer-bug branch March 1, 2023 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants