Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
bfa462a8
Commit
bfa462a8
authored
Dec 28, 2017
by
hzxuzhonghu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize volumeResizeMap lock
parent
18758f50
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
13 deletions
+6
-13
volume_resize_map.go
pkg/controller/volume/expand/cache/volume_resize_map.go
+6
-13
No files found.
pkg/controller/volume/expand/cache/volume_resize_map.go
View file @
bfa462a8
...
...
@@ -52,7 +52,7 @@ type volumeResizeMap struct {
// kube client for making API calls
kubeClient
clientset
.
Interface
// for guarding access to pvcrs map
sync
.
RW
Mutex
sync
.
Mutex
}
// PVCWithResizeRequest struct defines data structure that stores state needed for
...
...
@@ -103,9 +103,6 @@ func (resizeMap *volumeResizeMap) AddPVCUpdate(pvc *v1.PersistentVolumeClaim, pv
return
}
resizeMap
.
Lock
()
defer
resizeMap
.
Unlock
()
pvcSize
:=
pvc
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceStorage
]
pvcStatusSize
:=
pvc
.
Status
.
Capacity
[
v1
.
ResourceStorage
]
...
...
@@ -121,6 +118,9 @@ func (resizeMap *volumeResizeMap) AddPVCUpdate(pvc *v1.PersistentVolumeClaim, pv
ExpectedSize
:
pvcSize
,
PersistentVolume
:
pv
,
}
resizeMap
.
Lock
()
defer
resizeMap
.
Unlock
()
resizeMap
.
pvcrs
[
types
.
UniquePVCName
(
pvc
.
UID
)]
=
pvcRequest
}
...
...
@@ -141,18 +141,15 @@ func (resizeMap *volumeResizeMap) GetPVCsWithResizeRequest() []*PVCWithResizeReq
// DeletePVC removes given pvc object from list of pvcs that needs resizing.
// deleting a pvc in this map doesn't affect operations that are already inflight.
func
(
resizeMap
*
volumeResizeMap
)
DeletePVC
(
pvc
*
v1
.
PersistentVolumeClaim
)
{
resizeMap
.
Lock
()
defer
resizeMap
.
Unlock
()
pvcUniqueName
:=
types
.
UniquePVCName
(
pvc
.
UID
)
glog
.
V
(
5
)
.
Infof
(
"Removing PVC %v from resize map"
,
pvcUniqueName
)
resizeMap
.
Lock
()
defer
resizeMap
.
Unlock
()
delete
(
resizeMap
.
pvcrs
,
pvcUniqueName
)
}
// MarkAsResized marks a pvc as fully resized
func
(
resizeMap
*
volumeResizeMap
)
MarkAsResized
(
pvcr
*
PVCWithResizeRequest
,
newSize
resource
.
Quantity
)
error
{
resizeMap
.
Lock
()
defer
resizeMap
.
Unlock
()
emptyCondition
:=
[]
v1
.
PersistentVolumeClaimCondition
{}
err
:=
resizeMap
.
updatePVCCapacityAndConditions
(
pvcr
,
newSize
,
emptyCondition
)
...
...
@@ -165,9 +162,6 @@ func (resizeMap *volumeResizeMap) MarkAsResized(pvcr *PVCWithResizeRequest, newS
// UpdatePVSize updates just pv size after cloudprovider resizing is successful
func
(
resizeMap
*
volumeResizeMap
)
UpdatePVSize
(
pvcr
*
PVCWithResizeRequest
,
newSize
resource
.
Quantity
)
error
{
resizeMap
.
Lock
()
defer
resizeMap
.
Unlock
()
oldPv
:=
pvcr
.
PersistentVolume
pvClone
:=
oldPv
.
DeepCopy
()
...
...
@@ -201,7 +195,6 @@ func (resizeMap *volumeResizeMap) UpdatePVSize(pvcr *PVCWithResizeRequest, newSi
}
func
(
resizeMap
*
volumeResizeMap
)
updatePVCCapacityAndConditions
(
pvcr
*
PVCWithResizeRequest
,
newSize
resource
.
Quantity
,
pvcConditions
[]
v1
.
PersistentVolumeClaimCondition
)
error
{
claimClone
:=
pvcr
.
PVC
.
DeepCopy
()
claimClone
.
Status
.
Capacity
[
v1
.
ResourceStorage
]
=
newSize
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment