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: concurrent map write panic #16081

Merged
merged 2 commits into from
Nov 8, 2023
Merged

Conversation

sl1pm4t
Copy link
Contributor

@sl1pm4t sl1pm4t commented Nov 7, 2023

@justinsb this is the fix for the concurrent map write panic that we discussed.

It only occurs when kops is invoked by Terraform, which is parallelising updates to multiple instance groups at the same time.

The stack trace looked liked:

fatal error: concurrent map writes
fatal error: concurrent map writes

goroutine 102 [running]:
k8s.io/kops/upup/pkg/fi/cloudup/gce.CacheGCECloudInstance(...)
	/Users/matt/git/kops/upup/pkg/fi/cloudup/gce/gce_cloud.go:182
k8s.io/kops/upup/pkg/fi/cloudup/gce.NewGCECloud({0x14001c8a010, 0xb}, {0x14001ff1f96, 0xa}, 0x140007be720)
	/Users/matt/git/kops/upup/pkg/fi/cloudup/gce/gce_cloud.go:165 +0x4d0
k8s.io/kops/upup/pkg/fi/cloudup.BuildCloud(0x140006cd400)
	/Users/matt/git/kops/upup/pkg/fi/cloudup/utils.go:63 +0xd20
github.com/eddycharly/terraform-provider-kops/pkg/api/resources.UpdateInstanceGroup({_, _}, {_, _}, _, _, {{0x14001f063d0, 0xa}, {0x14001f06430, 0xc}, ...}, ...)
	/Users/matt/git/terraform-provider-kops/pkg/api/resources/InstanceGroup.go:104 +0x168
github.com/eddycharly/terraform-provider-kops/pkg/resources.InstanceGroupUpdate({0x105bda908, 0x140019c4e00}, 0x0?, {0x104aadf00?, 0x14000f59120?})
	/Users/matt/git/terraform-provider-kops/pkg/resources/InstanceGroup.go:44 +0xe0
...

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 7, 2023
@k8s-ci-robot k8s-ci-robot requested a review from hakman November 7, 2023 15:27
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 7, 2023
@k8s-ci-robot k8s-ci-robot added area/provider/gcp Issues or PRs related to gcp provider size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 7, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @sl1pm4t. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@hakman
Copy link
Member

hakman commented Nov 7, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 7, 2023
@hakman
Copy link
Member

hakman commented Nov 7, 2023

Shouldn't you also RLock and RUnlock the read(s)?

i := gceCloudInstances[region+"::"+project]

@sl1pm4t
Copy link
Contributor Author

sl1pm4t commented Nov 7, 2023

Yes, good call. I've pushed another commit with the RLock().

@sl1pm4t
Copy link
Contributor Author

sl1pm4t commented Nov 8, 2023

/test pull-kops-e2e-k8s-gce-ipalias

Copy link
Member

@hakman hakman left a comment

Choose a reason for hiding this comment

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

Thanks @sl1pm4t! 👍

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 8, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hakman

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 8, 2023
@k8s-ci-robot k8s-ci-robot merged commit e28a0c7 into kubernetes:master Nov 8, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.29 milestone Nov 8, 2023
@sl1pm4t sl1pm4t deleted the fix-panic branch November 8, 2023 17:48
sl1pm4t pushed a commit to sl1pm4t/kops that referenced this pull request Nov 15, 2023
sl1pm4t pushed a commit to sl1pm4t/kops that referenced this pull request Jan 24, 2024
sl1pm4t pushed a commit to sl1pm4t/kops that referenced this pull request Feb 13, 2024
sl1pm4t pushed a commit to sl1pm4t/kops that referenced this pull request Feb 15, 2024
sl1pm4t pushed a commit to sl1pm4t/kops that referenced this pull request Jun 15, 2024
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. area/provider/gcp Issues or PRs related to gcp provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

3 participants