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
0f62e3fb
Commit
0f62e3fb
authored
Aug 20, 2018
by
Hemant Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make language of error msgs and func names consistent: ExpandVolumeInUse
change feature flag Fix the e2e test for online and offline expansion
parent
acb321e6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
63 additions
and
20 deletions
+63
-20
kube_features.go
pkg/features/kube_features.go
+2
-2
reconciler.go
pkg/kubelet/volumemanager/reconciler/reconciler.go
+4
-4
fakegenerator.go
pkg/volume/util/operationexecutor/fakegenerator.go
+2
-2
operation_executor.go
pkg/volume/util/operationexecutor/operation_executor.go
+4
-4
operation_executor_test.go
pkg/volume/util/operationexecutor/operation_executor_test.go
+1
-1
operation_generator.go
pkg/volume/util/operationexecutor/operation_generator.go
+2
-2
volume_expand.go
test/e2e/storage/volume_expand.go
+48
-5
No files found.
pkg/features/kube_features.go
View file @
0f62e3fb
...
@@ -106,7 +106,7 @@ const (
...
@@ -106,7 +106,7 @@ const (
ExpandPersistentVolumes
featuregate
.
Feature
=
"ExpandPersistentVolumes"
ExpandPersistentVolumes
featuregate
.
Feature
=
"ExpandPersistentVolumes"
// owner: @mlmhl
// owner: @mlmhl
//
alpha: v1.11
//
beta: v1.15
// Ability to expand persistent volumes' file system without unmounting volumes.
// Ability to expand persistent volumes' file system without unmounting volumes.
ExpandInUsePersistentVolumes
featuregate
.
Feature
=
"ExpandInUsePersistentVolumes"
ExpandInUsePersistentVolumes
featuregate
.
Feature
=
"ExpandInUsePersistentVolumes"
...
@@ -507,7 +507,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
...
@@ -507,7 +507,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
TaintNodesByCondition
:
{
Default
:
true
,
PreRelease
:
featuregate
.
Beta
},
TaintNodesByCondition
:
{
Default
:
true
,
PreRelease
:
featuregate
.
Beta
},
QOSReserved
:
{
Default
:
false
,
PreRelease
:
featuregate
.
Alpha
},
QOSReserved
:
{
Default
:
false
,
PreRelease
:
featuregate
.
Alpha
},
ExpandPersistentVolumes
:
{
Default
:
true
,
PreRelease
:
featuregate
.
Beta
},
ExpandPersistentVolumes
:
{
Default
:
true
,
PreRelease
:
featuregate
.
Beta
},
ExpandInUsePersistentVolumes
:
{
Default
:
false
,
PreRelease
:
featuregate
.
Alph
a
},
ExpandInUsePersistentVolumes
:
{
Default
:
true
,
PreRelease
:
featuregate
.
Bet
a
},
ExpandCSIVolumes
:
{
Default
:
false
,
PreRelease
:
featuregate
.
Alpha
},
ExpandCSIVolumes
:
{
Default
:
false
,
PreRelease
:
featuregate
.
Alpha
},
AttachVolumeLimit
:
{
Default
:
true
,
PreRelease
:
featuregate
.
Beta
},
AttachVolumeLimit
:
{
Default
:
true
,
PreRelease
:
featuregate
.
Beta
},
CPUManager
:
{
Default
:
true
,
PreRelease
:
featuregate
.
Beta
},
CPUManager
:
{
Default
:
true
,
PreRelease
:
featuregate
.
Beta
},
...
...
pkg/kubelet/volumemanager/reconciler/reconciler.go
View file @
0f62e3fb
...
@@ -252,8 +252,8 @@ func (rc *reconciler) reconcile() {
...
@@ -252,8 +252,8 @@ func (rc *reconciler) reconcile() {
}
}
}
else
if
cache
.
IsFSResizeRequiredError
(
err
)
&&
}
else
if
cache
.
IsFSResizeRequiredError
(
err
)
&&
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
ExpandInUsePersistentVolumes
)
{
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
ExpandInUsePersistentVolumes
)
{
klog
.
V
(
4
)
.
Infof
(
volumeToMount
.
GenerateMsgDetailed
(
"Starting operationExecutor.Expand
VolumeFSWithoutUnmounting
"
,
""
))
klog
.
V
(
4
)
.
Infof
(
volumeToMount
.
GenerateMsgDetailed
(
"Starting operationExecutor.Expand
InUseVolume
"
,
""
))
err
:=
rc
.
operationExecutor
.
Expand
VolumeFSWithoutUnmounting
(
err
:=
rc
.
operationExecutor
.
Expand
InUseVolume
(
volumeToMount
.
VolumeToMount
,
volumeToMount
.
VolumeToMount
,
rc
.
actualStateOfWorld
)
rc
.
actualStateOfWorld
)
if
err
!=
nil
&&
if
err
!=
nil
&&
...
@@ -261,10 +261,10 @@ func (rc *reconciler) reconcile() {
...
@@ -261,10 +261,10 @@ func (rc *reconciler) reconcile() {
!
exponentialbackoff
.
IsExponentialBackoff
(
err
)
{
!
exponentialbackoff
.
IsExponentialBackoff
(
err
)
{
// Ignore nestedpendingoperations.IsAlreadyExists and exponentialbackoff.IsExponentialBackoff errors, they are expected.
// Ignore nestedpendingoperations.IsAlreadyExists and exponentialbackoff.IsExponentialBackoff errors, they are expected.
// Log all other errors.
// Log all other errors.
klog
.
Errorf
(
volumeToMount
.
GenerateErrorDetailed
(
"operationExecutor.Expand
VolumeFSWithoutUnmounting
failed"
,
err
)
.
Error
())
klog
.
Errorf
(
volumeToMount
.
GenerateErrorDetailed
(
"operationExecutor.Expand
InUseVolume
failed"
,
err
)
.
Error
())
}
}
if
err
==
nil
{
if
err
==
nil
{
klog
.
V
(
4
)
.
Infof
(
volumeToMount
.
GenerateMsgDetailed
(
"operationExecutor.Expand
VolumeFSWithoutUnmounting
started"
,
""
))
klog
.
V
(
4
)
.
Infof
(
volumeToMount
.
GenerateMsgDetailed
(
"operationExecutor.Expand
InUseVolume
started"
,
""
))
}
}
}
}
}
}
...
...
pkg/volume/util/operationexecutor/fakegenerator.go
View file @
0f62e3fb
...
@@ -99,8 +99,8 @@ func (f *fakeOGCounter) GenerateExpandVolumeFunc(*v1.PersistentVolumeClaim, *v1.
...
@@ -99,8 +99,8 @@ func (f *fakeOGCounter) GenerateExpandVolumeFunc(*v1.PersistentVolumeClaim, *v1.
return
f
.
recordFuncCall
(
"GenerateExpandVolumeFunc"
),
nil
return
f
.
recordFuncCall
(
"GenerateExpandVolumeFunc"
),
nil
}
}
func
(
f
*
fakeOGCounter
)
GenerateExpand
VolumeFSWithoutUnmounting
Func
(
volumeToMount
VolumeToMount
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
)
(
volumetypes
.
GeneratedOperations
,
error
)
{
func
(
f
*
fakeOGCounter
)
GenerateExpand
InUseVolume
Func
(
volumeToMount
VolumeToMount
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
)
(
volumetypes
.
GeneratedOperations
,
error
)
{
return
f
.
recordFuncCall
(
"GenerateExpand
VolumeFSWithoutUnmounting
Func"
),
nil
return
f
.
recordFuncCall
(
"GenerateExpand
InUseVolume
Func"
),
nil
}
}
func
(
f
*
fakeOGCounter
)
recordFuncCall
(
name
string
)
volumetypes
.
GeneratedOperations
{
func
(
f
*
fakeOGCounter
)
recordFuncCall
(
name
string
)
volumetypes
.
GeneratedOperations
{
...
...
pkg/volume/util/operationexecutor/operation_executor.go
View file @
0f62e3fb
...
@@ -140,8 +140,8 @@ type OperationExecutor interface {
...
@@ -140,8 +140,8 @@ type OperationExecutor interface {
// IsOperationPending returns true if an operation for the given volumeName and podName is pending,
// IsOperationPending returns true if an operation for the given volumeName and podName is pending,
// otherwise it returns false
// otherwise it returns false
IsOperationPending
(
volumeName
v1
.
UniqueVolumeName
,
podName
volumetypes
.
UniquePodName
)
bool
IsOperationPending
(
volumeName
v1
.
UniqueVolumeName
,
podName
volumetypes
.
UniquePodName
)
bool
// Expand
VolumeFSWithoutUnmounting
will resize volume's file system to expected size without unmounting the volume.
// Expand
InUseVolume
will resize volume's file system to expected size without unmounting the volume.
Expand
VolumeFSWithoutUnmounting
(
volumeToMount
VolumeToMount
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
)
error
Expand
InUseVolume
(
volumeToMount
VolumeToMount
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
)
error
// ReconstructVolumeOperation construct a new volumeSpec and returns it created by plugin
// ReconstructVolumeOperation construct a new volumeSpec and returns it created by plugin
ReconstructVolumeOperation
(
volumeMode
v1
.
PersistentVolumeMode
,
plugin
volume
.
VolumePlugin
,
mapperPlugin
volume
.
BlockVolumePlugin
,
uid
types
.
UID
,
podName
volumetypes
.
UniquePodName
,
volumeSpecName
string
,
volumePath
string
,
pluginName
string
)
(
*
volume
.
Spec
,
error
)
ReconstructVolumeOperation
(
volumeMode
v1
.
PersistentVolumeMode
,
plugin
volume
.
VolumePlugin
,
mapperPlugin
volume
.
BlockVolumePlugin
,
uid
types
.
UID
,
podName
volumetypes
.
UniquePodName
,
volumeSpecName
string
,
volumePath
string
,
pluginName
string
)
(
*
volume
.
Spec
,
error
)
// CheckVolumeExistenceOperation checks volume existence
// CheckVolumeExistenceOperation checks volume existence
...
@@ -820,8 +820,8 @@ func (oe *operationExecutor) UnmountDevice(
...
@@ -820,8 +820,8 @@ func (oe *operationExecutor) UnmountDevice(
deviceToDetach
.
VolumeName
,
podName
,
generatedOperations
)
deviceToDetach
.
VolumeName
,
podName
,
generatedOperations
)
}
}
func
(
oe
*
operationExecutor
)
Expand
VolumeFSWithoutUnmounting
(
volumeToMount
VolumeToMount
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
)
error
{
func
(
oe
*
operationExecutor
)
Expand
InUseVolume
(
volumeToMount
VolumeToMount
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
)
error
{
generatedOperations
,
err
:=
oe
.
operationGenerator
.
GenerateExpand
VolumeFSWithoutUnmounting
Func
(
volumeToMount
,
actualStateOfWorld
)
generatedOperations
,
err
:=
oe
.
operationGenerator
.
GenerateExpand
InUseVolume
Func
(
volumeToMount
,
actualStateOfWorld
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/volume/util/operationexecutor/operation_executor_test.go
View file @
0f62e3fb
...
@@ -462,7 +462,7 @@ func (fopg *fakeOperationGenerator) GenerateExpandVolumeFunc(pvc *v1.PersistentV
...
@@ -462,7 +462,7 @@ func (fopg *fakeOperationGenerator) GenerateExpandVolumeFunc(pvc *v1.PersistentV
},
nil
},
nil
}
}
func
(
fopg
*
fakeOperationGenerator
)
GenerateExpand
VolumeFSWithoutUnmounting
Func
(
volumeToMount
VolumeToMount
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
)
(
volumetypes
.
GeneratedOperations
,
error
)
{
func
(
fopg
*
fakeOperationGenerator
)
GenerateExpand
InUseVolume
Func
(
volumeToMount
VolumeToMount
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
)
(
volumetypes
.
GeneratedOperations
,
error
)
{
opFunc
:=
func
()
(
error
,
error
)
{
opFunc
:=
func
()
(
error
,
error
)
{
startOperationAndBlock
(
fopg
.
ch
,
fopg
.
quit
)
startOperationAndBlock
(
fopg
.
ch
,
fopg
.
quit
)
return
nil
,
nil
return
nil
,
nil
...
...
pkg/volume/util/operationexecutor/operation_generator.go
View file @
0f62e3fb
...
@@ -131,7 +131,7 @@ type OperationGenerator interface {
...
@@ -131,7 +131,7 @@ type OperationGenerator interface {
GenerateExpandVolumeFunc
(
*
v1
.
PersistentVolumeClaim
,
*
v1
.
PersistentVolume
)
(
volumetypes
.
GeneratedOperations
,
error
)
GenerateExpandVolumeFunc
(
*
v1
.
PersistentVolumeClaim
,
*
v1
.
PersistentVolume
)
(
volumetypes
.
GeneratedOperations
,
error
)
// Generates the volume file system resize function, which can resize volume's file system to expected size without unmounting the volume.
// Generates the volume file system resize function, which can resize volume's file system to expected size without unmounting the volume.
GenerateExpand
VolumeFSWithoutUnmounting
Func
(
volumeToMount
VolumeToMount
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
)
(
volumetypes
.
GeneratedOperations
,
error
)
GenerateExpand
InUseVolume
Func
(
volumeToMount
VolumeToMount
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
)
(
volumetypes
.
GeneratedOperations
,
error
)
}
}
func
(
og
*
operationGenerator
)
GenerateVolumesAreAttachedFunc
(
func
(
og
*
operationGenerator
)
GenerateVolumesAreAttachedFunc
(
...
@@ -1578,7 +1578,7 @@ func (og *operationGenerator) GenerateExpandVolumeFunc(
...
@@ -1578,7 +1578,7 @@ func (og *operationGenerator) GenerateExpandVolumeFunc(
},
nil
},
nil
}
}
func
(
og
*
operationGenerator
)
GenerateExpand
VolumeFSWithoutUnmounting
Func
(
func
(
og
*
operationGenerator
)
GenerateExpand
InUseVolume
Func
(
volumeToMount
VolumeToMount
,
volumeToMount
VolumeToMount
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
)
(
volumetypes
.
GeneratedOperations
,
error
)
{
actualStateOfWorld
ActualStateOfWorldMounterUpdater
)
(
volumetypes
.
GeneratedOperations
,
error
)
{
...
...
test/e2e/storage/volume_expand.go
View file @
0f62e3fb
...
@@ -104,7 +104,7 @@ var _ = utils.SIGDescribe("Volume expand", func() {
...
@@ -104,7 +104,7 @@ var _ = utils.SIGDescribe("Volume expand", func() {
framework
.
ExpectError
(
err
,
"While updating non-expandable PVC"
)
framework
.
ExpectError
(
err
,
"While updating non-expandable PVC"
)
})
})
ginkgo
.
It
(
"Verify if
editing PVC allows resize
"
,
func
()
{
ginkgo
.
It
(
"Verify if
offline PVC expansion works
"
,
func
()
{
pvc
,
storageClassVar
,
err
=
setupFunc
(
true
/* allowExpansion */
,
false
/*BlockVolume*/
)
pvc
,
storageClassVar
,
err
=
setupFunc
(
true
/* allowExpansion */
,
false
/*BlockVolume*/
)
framework
.
ExpectNoError
(
err
,
"Error creating non-expandable PVC"
)
framework
.
ExpectNoError
(
err
,
"Error creating non-expandable PVC"
)
...
@@ -122,6 +122,11 @@ var _ = utils.SIGDescribe("Volume expand", func() {
...
@@ -122,6 +122,11 @@ var _ = utils.SIGDescribe("Volume expand", func() {
framework
.
ExpectNoError
(
err
,
"while cleaning up pod already deleted in resize test"
)
framework
.
ExpectNoError
(
err
,
"while cleaning up pod already deleted in resize test"
)
}()
}()
ginkgo
.
By
(
"Deleting the previously created pod"
)
err
=
framework
.
DeletePodWithWait
(
f
,
c
,
pod
)
framework
.
ExpectNoError
(
err
,
"while deleting pod for resizing"
)
// We expand the PVC while no pod is using it to ensure offline expansion
ginkgo
.
By
(
"Expanding current pvc"
)
ginkgo
.
By
(
"Expanding current pvc"
)
newSize
:=
resource
.
MustParse
(
"6Gi"
)
newSize
:=
resource
.
MustParse
(
"6Gi"
)
pvc
,
err
=
expandPVCSize
(
pvc
,
newSize
,
c
)
pvc
,
err
=
expandPVCSize
(
pvc
,
newSize
,
c
)
...
@@ -145,10 +150,6 @@ var _ = utils.SIGDescribe("Volume expand", func() {
...
@@ -145,10 +150,6 @@ var _ = utils.SIGDescribe("Volume expand", func() {
gomega
.
Expect
(
len
(
inProgressConditions
))
.
To
(
gomega
.
Equal
(
1
),
"pvc must have file system resize pending condition"
)
gomega
.
Expect
(
len
(
inProgressConditions
))
.
To
(
gomega
.
Equal
(
1
),
"pvc must have file system resize pending condition"
)
gomega
.
Expect
(
inProgressConditions
[
0
]
.
Type
)
.
To
(
gomega
.
Equal
(
v1
.
PersistentVolumeClaimFileSystemResizePending
),
"pvc must have fs resizing condition"
)
gomega
.
Expect
(
inProgressConditions
[
0
]
.
Type
)
.
To
(
gomega
.
Equal
(
v1
.
PersistentVolumeClaimFileSystemResizePending
),
"pvc must have fs resizing condition"
)
ginkgo
.
By
(
"Deleting the previously created pod"
)
err
=
framework
.
DeletePodWithWait
(
f
,
c
,
pod
)
framework
.
ExpectNoError
(
err
,
"while deleting pod for resizing"
)
ginkgo
.
By
(
"Creating a new pod with same volume"
)
ginkgo
.
By
(
"Creating a new pod with same volume"
)
pod2
,
err
:=
framework
.
CreatePod
(
c
,
ns
,
nil
,
pvcClaims
,
false
,
""
)
pod2
,
err
:=
framework
.
CreatePod
(
c
,
ns
,
nil
,
pvcClaims
,
false
,
""
)
framework
.
ExpectNoError
(
err
,
"while recreating pod for resizing"
)
framework
.
ExpectNoError
(
err
,
"while recreating pod for resizing"
)
...
@@ -165,6 +166,48 @@ var _ = utils.SIGDescribe("Volume expand", func() {
...
@@ -165,6 +166,48 @@ var _ = utils.SIGDescribe("Volume expand", func() {
gomega
.
Expect
(
len
(
pvcConditions
))
.
To
(
gomega
.
Equal
(
0
),
"pvc should not have conditions"
)
gomega
.
Expect
(
len
(
pvcConditions
))
.
To
(
gomega
.
Equal
(
0
),
"pvc should not have conditions"
)
})
})
ginkgo
.
It
(
"should resize volume when PVC is edited while pod is using it"
,
func
()
{
pvc
,
storageClassVar
,
err
=
setupFunc
(
true
/* allowExpansion */
,
false
/*BlockVolume*/
)
framework
.
ExpectNoError
(
err
,
"Error creating non-expandable PVC"
)
ginkgo
.
By
(
"Waiting for pvc to be in bound phase"
)
pvcClaims
:=
[]
*
v1
.
PersistentVolumeClaim
{
pvc
}
pvs
,
err
:=
framework
.
WaitForPVClaimBoundPhase
(
c
,
pvcClaims
,
framework
.
ClaimProvisionTimeout
)
framework
.
ExpectNoError
(
err
,
"Failed waiting for PVC to be bound %v"
,
err
)
gomega
.
Expect
(
len
(
pvs
))
.
To
(
gomega
.
Equal
(
1
))
ginkgo
.
By
(
"Creating a pod with dynamically provisioned volume"
)
pod
,
err
:=
framework
.
CreatePod
(
c
,
ns
,
nil
,
pvcClaims
,
false
,
""
)
framework
.
ExpectNoError
(
err
,
"While creating pods for resizing"
)
defer
func
()
{
err
=
framework
.
DeletePodWithWait
(
f
,
c
,
pod
)
framework
.
ExpectNoError
(
err
,
"while cleaning up pod already deleted in resize test"
)
}()
// We expand the PVC while no pod is using it to ensure online expansion
ginkgo
.
By
(
"Expanding current pvc"
)
newSize
:=
resource
.
MustParse
(
"6Gi"
)
pvc
,
err
=
expandPVCSize
(
pvc
,
newSize
,
c
)
framework
.
ExpectNoError
(
err
,
"While updating pvc for more size"
)
gomega
.
Expect
(
pvc
)
.
NotTo
(
gomega
.
BeNil
())
pvcSize
:=
pvc
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceStorage
]
if
pvcSize
.
Cmp
(
newSize
)
!=
0
{
framework
.
Failf
(
"error updating pvc size %q"
,
pvc
.
Name
)
}
ginkgo
.
By
(
"Waiting for cloudprovider resize to finish"
)
err
=
waitForControllerVolumeResize
(
pvc
,
c
,
totalResizeWaitPeriod
)
framework
.
ExpectNoError
(
err
,
"While waiting for pvc resize to finish"
)
ginkgo
.
By
(
"Waiting for file system resize to finish"
)
pvc
,
err
=
waitForFSResize
(
pvc
,
c
)
framework
.
ExpectNoError
(
err
,
"while waiting for fs resize to finish"
)
pvcConditions
:=
pvc
.
Status
.
Conditions
gomega
.
Expect
(
len
(
pvcConditions
))
.
To
(
gomega
.
Equal
(
0
),
"pvc should not have conditions"
)
})
ginkgo
.
It
(
"should allow expansion of block volumes"
,
func
()
{
ginkgo
.
It
(
"should allow expansion of block volumes"
,
func
()
{
pvc
,
storageClassVar
,
err
=
setupFunc
(
true
/*allowExpansion*/
,
true
/*blockVolume*/
)
pvc
,
storageClassVar
,
err
=
setupFunc
(
true
/*allowExpansion*/
,
true
/*blockVolume*/
)
...
...
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