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
0ad846cb
Commit
0ad846cb
authored
Sep 26, 2017
by
Hemant Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add documentation comments for volume expand controller
These comments help clear out some of the design choices made in code.
parent
52f96dae
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
volume_resize_map.go
pkg/controller/volume/expand/cache/volume_resize_map.go
+5
-0
pvc_populator.go
pkg/controller/volume/expand/pvc_populator.go
+5
-0
operation_generator.go
pkg/volume/util/operationexecutor/operation_generator.go
+5
-0
No files found.
pkg/controller/volume/expand/cache/volume_resize_map.go
View file @
0ad846cb
...
@@ -88,6 +88,11 @@ func NewVolumeResizeMap(kubeClient clientset.Interface) VolumeResizeMap {
...
@@ -88,6 +88,11 @@ func NewVolumeResizeMap(kubeClient clientset.Interface) VolumeResizeMap {
}
}
// AddPVCUpdate adds pvc for resizing
// AddPVCUpdate adds pvc for resizing
// This function intentionally allows addition of PVCs for which pv.Spec.Size >= pvc.Spec.Size,
// the reason being - lack of transaction in k8s means after successful resize, we can't guarantee that when we update PV,
// pvc update will be successful too and after resize we alyways update PV first.
// If for some reason we weren't able to update PVC after successful resize, then we are going to reprocess
// the PVC and hopefully after a no-op resize in volume plugin, PVC will be updated with right values as well.
func
(
resizeMap
*
volumeResizeMap
)
AddPVCUpdate
(
pvc
*
v1
.
PersistentVolumeClaim
,
pv
*
v1
.
PersistentVolume
)
{
func
(
resizeMap
*
volumeResizeMap
)
AddPVCUpdate
(
pvc
*
v1
.
PersistentVolumeClaim
,
pv
*
v1
.
PersistentVolume
)
{
if
pv
.
Spec
.
ClaimRef
==
nil
||
pvc
.
Namespace
!=
pv
.
Spec
.
ClaimRef
.
Namespace
||
pvc
.
Name
!=
pv
.
Spec
.
ClaimRef
.
Name
{
if
pv
.
Spec
.
ClaimRef
==
nil
||
pvc
.
Namespace
!=
pv
.
Spec
.
ClaimRef
.
Namespace
||
pvc
.
Name
!=
pv
.
Spec
.
ClaimRef
.
Name
{
glog
.
V
(
4
)
.
Infof
(
"Persistent Volume is not bound to PVC being updated : %s"
,
util
.
ClaimToClaimKey
(
pvc
))
glog
.
V
(
4
)
.
Infof
(
"Persistent Volume is not bound to PVC being updated : %s"
,
util
.
ClaimToClaimKey
(
pvc
))
...
...
pkg/controller/volume/expand/pvc_populator.go
View file @
0ad846cb
...
@@ -80,6 +80,11 @@ func (populator *pvcPopulator) Sync() {
...
@@ -80,6 +80,11 @@ func (populator *pvcPopulator) Sync() {
glog
.
V
(
5
)
.
Infof
(
"Error getting persistent volume for pvc %q : %v"
,
pvc
.
UID
,
err
)
glog
.
V
(
5
)
.
Infof
(
"Error getting persistent volume for pvc %q : %v"
,
pvc
.
UID
,
err
)
continue
continue
}
}
// We are only going to add PVCs which are:
// - bound
// - pvc.Spec.Size > pvc.Status.Size
// These 2 checks are already performed in AddPVCUpdate function before adding pvc for resize
// and hence we do not repeat those checks here.
populator
.
resizeMap
.
AddPVCUpdate
(
pvc
,
pv
)
populator
.
resizeMap
.
AddPVCUpdate
(
pvc
,
pv
)
}
}
}
}
pkg/volume/util/operationexecutor/operation_generator.go
View file @
0ad846cb
...
@@ -756,6 +756,9 @@ func (og *operationGenerator) GenerateExpandVolumeFunc(
...
@@ -756,6 +756,9 @@ func (og *operationGenerator) GenerateExpandVolumeFunc(
return
expandErr
return
expandErr
}
}
newSize
=
updatedSize
newSize
=
updatedSize
// k8s doesn't have transactions, we can't guarantee that after updating PV - updating PVC will be
// successful, that is why all PVCs for which pvc.Spec.Size > pvc.Status.Size must be reprocessed
// until they reflect user requested size in pvc.Status.Size
updateErr
:=
resizeMap
.
UpdatePVSize
(
pvcWithResizeRequest
,
newSize
)
updateErr
:=
resizeMap
.
UpdatePVSize
(
pvcWithResizeRequest
,
newSize
)
if
updateErr
!=
nil
{
if
updateErr
!=
nil
{
...
@@ -766,6 +769,8 @@ func (og *operationGenerator) GenerateExpandVolumeFunc(
...
@@ -766,6 +769,8 @@ func (og *operationGenerator) GenerateExpandVolumeFunc(
}
}
// No Cloudprovider resize needed, lets mark resizing as done
// No Cloudprovider resize needed, lets mark resizing as done
// Rest of the volume expand controller code will assume PVC as *not* resized until pvc.Status.Size
// reflects user requested size.
if
!
volumePlugin
.
RequiresFSResize
()
{
if
!
volumePlugin
.
RequiresFSResize
()
{
glog
.
V
(
4
)
.
Infof
(
"Controller resizing done for PVC %s"
,
pvcWithResizeRequest
.
QualifiedName
())
glog
.
V
(
4
)
.
Infof
(
"Controller resizing done for PVC %s"
,
pvcWithResizeRequest
.
QualifiedName
())
err
:=
resizeMap
.
MarkAsResized
(
pvcWithResizeRequest
,
newSize
)
err
:=
resizeMap
.
MarkAsResized
(
pvcWithResizeRequest
,
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