Skip to content

bug fix: kubeclientmgr.Pick should be concurrent safe#1209

Merged
centaurus-cloud-bot merged 1 commit intoCentaurusInfra:masterfrom
h-w-chen:hw-kubeclient-manager-concurrency-defect-fix
Oct 8, 2021
Merged

bug fix: kubeclientmgr.Pick should be concurrent safe#1209
centaurus-cloud-bot merged 1 commit intoCentaurusInfra:masterfrom
h-w-chen:hw-kubeclient-manager-concurrency-defect-fix

Conversation

@h-w-chen
Copy link
Collaborator

@h-w-chen h-w-chen commented Oct 8, 2021

What type of PR is this?
/kind bug

What this PR does / why we need it:
This PR fixes a subtle defect caused by code change to kubeclientmanager (original code did not have such bug).

Pick method was exposed public; however access to its internal shared data is not guarded properly with the exposure.

Does this PR introduce a user-facing change?:

NONE


func (manager *KubeClientManager) PickClient(tenant string) int {
manager.tenant2apiLock.RLock()
defer manager.tenant2apiLock.RUnlock()
Copy link
Collaborator

Choose a reason for hiding this comment

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

the purpose of the fix is to reduce the lock window, if so, let's explicitly call RUnlock() after the map read.

Copy link
Collaborator

@q131172019 q131172019 left a comment

Choose a reason for hiding this comment

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

/LGTM

@zmn223
Copy link
Collaborator

zmn223 commented Oct 8, 2021

/approve

@centaurus-cloud-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: q131172019, zmn223

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

The pull request process is described here

Details 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

@centaurus-cloud-bot centaurus-cloud-bot merged commit 8f42784 into CentaurusInfra:master Oct 8, 2021
@CKchen0726
Copy link

/approve

Hi, could you invite me to arktos slack channel? Thanks.
PS: email: chenchangkuan@huawei.com

click2cloud-amit pushed a commit to Click2Cloud-Centaurus/arktos that referenced this pull request Oct 14, 2021
@h-w-chen h-w-chen deleted the hw-kubeclient-manager-concurrency-defect-fix branch October 18, 2021 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants