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
9e52832c
Unverified
Commit
9e52832c
authored
May 01, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 01, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #77317 from gnufied/fix-block-volume-resizing
Fix block volume expansion
parents
3b5e2285
0eb68c5a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
37 deletions
+72
-37
operation_generator.go
pkg/volume/util/operationexecutor/operation_generator.go
+2
-1
provisioning.go
test/e2e/storage/testsuites/provisioning.go
+1
-1
volume_expand.go
test/e2e/storage/volume_expand.go
+63
-34
volume_provisioning.go
test/e2e/storage/volume_provisioning.go
+6
-1
No files found.
pkg/volume/util/operationexecutor/operation_generator.go
View file @
9e52832c
...
@@ -1537,10 +1537,11 @@ func (og *operationGenerator) GenerateExpandVolumeFunc(
...
@@ -1537,10 +1537,11 @@ func (og *operationGenerator) GenerateExpandVolumeFunc(
klog
.
Infof
(
"ExpandVolume.UpdatePV succeeded for volume %s"
,
pvcWithResizeRequest
.
QualifiedName
())
klog
.
Infof
(
"ExpandVolume.UpdatePV succeeded for volume %s"
,
pvcWithResizeRequest
.
QualifiedName
())
}
}
fsVolume
,
_
:=
util
.
CheckVolumeModeFilesystem
(
volumeSpec
)
// 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
// Rest of the volume expand controller code will assume PVC as *not* resized until pvc.Status.Size
// reflects user requested size.
// reflects user requested size.
if
!
volumePlugin
.
RequiresFSResize
()
{
if
!
volumePlugin
.
RequiresFSResize
()
||
!
fsVolume
{
klog
.
V
(
4
)
.
Infof
(
"Controller resizing done for PVC %s"
,
pvcWithResizeRequest
.
QualifiedName
())
klog
.
V
(
4
)
.
Infof
(
"Controller resizing done for PVC %s"
,
pvcWithResizeRequest
.
QualifiedName
())
err
:=
resizeMap
.
MarkAsResized
(
pvcWithResizeRequest
,
newSize
)
err
:=
resizeMap
.
MarkAsResized
(
pvcWithResizeRequest
,
newSize
)
...
...
test/e2e/storage/testsuites/provisioning.go
View file @
9e52832c
...
@@ -53,7 +53,7 @@ type StorageClassTest struct {
...
@@ -53,7 +53,7 @@ type StorageClassTest struct {
ClaimSize
string
ClaimSize
string
ExpectedSize
string
ExpectedSize
string
PvCheck
func
(
claim
*
v1
.
PersistentVolumeClaim
)
PvCheck
func
(
claim
*
v1
.
PersistentVolumeClaim
)
VolumeMode
*
v1
.
PersistentVolumeMode
VolumeMode
v1
.
PersistentVolumeMode
AllowVolumeExpansion
bool
AllowVolumeExpansion
bool
}
}
...
...
test/e2e/storage/volume_expand.go
View file @
9e52832c
...
@@ -46,7 +46,7 @@ var _ = utils.SIGDescribe("Volume expand", func() {
...
@@ -46,7 +46,7 @@ var _ = utils.SIGDescribe("Volume expand", func() {
ns
string
ns
string
err
error
err
error
pvc
*
v1
.
PersistentVolumeClaim
pvc
*
v1
.
PersistentVolumeClaim
resizableSc
*
storage
.
StorageClass
storageClassVar
*
storage
.
StorageClass
)
)
f
:=
framework
.
NewDefaultFramework
(
"volume-expand"
)
f
:=
framework
.
NewDefaultFramework
(
"volume-expand"
)
...
@@ -55,61 +55,58 @@ var _ = utils.SIGDescribe("Volume expand", func() {
...
@@ -55,61 +55,58 @@ var _ = utils.SIGDescribe("Volume expand", func() {
c
=
f
.
ClientSet
c
=
f
.
ClientSet
ns
=
f
.
Namespace
.
Name
ns
=
f
.
Namespace
.
Name
framework
.
ExpectNoError
(
framework
.
WaitForAllNodesSchedulable
(
c
,
framework
.
TestContext
.
NodeSchedulableTimeout
))
framework
.
ExpectNoError
(
framework
.
WaitForAllNodesSchedulable
(
c
,
framework
.
TestContext
.
NodeSchedulableTimeout
))
})
setupFunc
:=
func
(
allowExpansion
bool
,
blockVolume
bool
)
(
*
v1
.
PersistentVolumeClaim
,
*
storage
.
StorageClass
,
error
)
{
test
:=
testsuites
.
StorageClassTest
{
test
:=
testsuites
.
StorageClassTest
{
Name
:
"default"
,
Name
:
"default"
,
ClaimSize
:
"2Gi"
,
ClaimSize
:
"2Gi"
,
AllowVolumeExpansion
:
true
,
}
}
resizableSc
,
err
=
createStorageClass
(
test
,
ns
,
"resizing"
,
c
)
if
allowExpansion
{
framework
.
ExpectNoError
(
err
,
"Error creating resizable storage class"
)
test
.
AllowVolumeExpansion
=
true
Expect
(
resizableSc
.
AllowVolumeExpansion
)
.
NotTo
(
BeNil
())
}
Expect
(
*
resizableSc
.
AllowVolumeExpansion
)
.
To
(
BeTrue
())
if
blockVolume
{
test
.
VolumeMode
=
v1
.
PersistentVolumeBlock
pvc
=
newClaim
(
test
,
ns
,
"default"
)
}
pvc
.
Spec
.
StorageClassName
=
&
resizableSc
.
Name
pvc
,
err
=
c
.
CoreV1
()
.
PersistentVolumeClaims
(
pvc
.
Namespace
)
.
Create
(
pvc
)
sc
,
err
:=
createStorageClass
(
test
,
ns
,
"resizing"
,
c
)
framework
.
ExpectNoError
(
err
,
"Error creating pvc"
)
framework
.
ExpectNoError
(
err
,
"Error creating storage class for resizing"
)
})
tPVC
:=
newClaim
(
test
,
ns
,
"default"
)
tPVC
.
Spec
.
StorageClassName
=
&
sc
.
Name
tPVC
,
err
=
c
.
CoreV1
()
.
PersistentVolumeClaims
(
tPVC
.
Namespace
)
.
Create
(
tPVC
)
if
err
!=
nil
{
return
nil
,
sc
,
err
}
return
tPVC
,
sc
,
nil
}
AfterEach
(
func
()
{
AfterEach
(
func
()
{
framework
.
ExpectNoError
(
framework
.
DeletePersistentVolumeClaim
(
c
,
pvc
.
Name
,
pvc
.
Namespace
))
framework
.
ExpectNoError
(
framework
.
DeletePersistentVolumeClaim
(
c
,
pvc
.
Name
,
pvc
.
Namespace
))
framework
.
ExpectNoError
(
c
.
StorageV1
()
.
StorageClasses
()
.
Delete
(
resizableSc
.
Name
,
nil
))
framework
.
ExpectNoError
(
c
.
StorageV1
()
.
StorageClasses
()
.
Delete
(
storageClassVar
.
Name
,
nil
))
})
})
It
(
"should not allow expansion of pvcs without AllowVolumeExpansion property"
,
func
()
{
It
(
"should not allow expansion of pvcs without AllowVolumeExpansion property"
,
func
()
{
test
:=
testsuites
.
StorageClassTest
{
pvc
,
storageClassVar
,
err
=
setupFunc
(
false
/* allowExpansion */
,
false
/*BlockVolume*/
)
Name
:
"no-expansion"
,
framework
.
ExpectNoError
(
err
,
"Error creating non-expandable PVC"
)
ClaimSize
:
"2Gi"
,
}
regularSC
,
err
:=
createStorageClass
(
test
,
ns
,
"noexpand"
,
c
)
framework
.
ExpectNoError
(
err
,
"Error creating non-expandable storage class"
)
defer
func
()
{
Expect
(
storageClassVar
.
AllowVolumeExpansion
)
.
To
(
BeNil
())
framework
.
ExpectNoError
(
c
.
StorageV1
()
.
StorageClasses
()
.
Delete
(
regularSC
.
Name
,
nil
))
}()
Expect
(
regularSC
.
AllowVolumeExpansion
)
.
To
(
BeNil
())
noExpandPVC
:=
newClaim
(
test
,
ns
,
"noexpand"
)
pvcClaims
:=
[]
*
v1
.
PersistentVolumeClaim
{
pvc
}
noExpandPVC
.
Spec
.
StorageClassName
=
&
regularSC
.
Name
noExpandPVC
,
err
=
c
.
CoreV1
()
.
PersistentVolumeClaims
(
noExpandPVC
.
Namespace
)
.
Create
(
noExpandPVC
)
framework
.
ExpectNoError
(
err
,
"Error creating pvc"
)
defer
func
()
{
framework
.
ExpectNoError
(
framework
.
DeletePersistentVolumeClaim
(
c
,
noExpandPVC
.
Name
,
noExpandPVC
.
Namespace
))
}()
pvcClaims
:=
[]
*
v1
.
PersistentVolumeClaim
{
noExpandPVC
}
pvs
,
err
:=
framework
.
WaitForPVClaimBoundPhase
(
c
,
pvcClaims
,
framework
.
ClaimProvisionTimeout
)
pvs
,
err
:=
framework
.
WaitForPVClaimBoundPhase
(
c
,
pvcClaims
,
framework
.
ClaimProvisionTimeout
)
framework
.
ExpectNoError
(
err
,
"Failed waiting for PVC to be bound %v"
,
err
)
framework
.
ExpectNoError
(
err
,
"Failed waiting for PVC to be bound %v"
,
err
)
Expect
(
len
(
pvs
))
.
To
(
Equal
(
1
))
Expect
(
len
(
pvs
))
.
To
(
Equal
(
1
))
By
(
"Expanding non-expandable pvc"
)
By
(
"Expanding non-expandable pvc"
)
newSize
:=
resource
.
MustParse
(
"6Gi"
)
newSize
:=
resource
.
MustParse
(
"6Gi"
)
noExpandPVC
,
err
=
expandPVCSize
(
noExpandPVC
,
newSize
,
c
)
pvc
,
err
=
expandPVCSize
(
pvc
,
newSize
,
c
)
Expect
(
err
)
.
To
(
HaveOccurred
(),
"While updating non-expandable PVC"
)
Expect
(
err
)
.
To
(
HaveOccurred
(),
"While updating non-expandable PVC"
)
})
})
It
(
"Verify if editing PVC allows resize"
,
func
()
{
It
(
"Verify if editing PVC allows resize"
,
func
()
{
pvc
,
storageClassVar
,
err
=
setupFunc
(
true
/* allowExpansion */
,
false
/*BlockVolume*/
)
framework
.
ExpectNoError
(
err
,
"Error creating non-expandable PVC"
)
By
(
"Waiting for pvc to be in bound phase"
)
By
(
"Waiting for pvc to be in bound phase"
)
pvcClaims
:=
[]
*
v1
.
PersistentVolumeClaim
{
pvc
}
pvcClaims
:=
[]
*
v1
.
PersistentVolumeClaim
{
pvc
}
pvs
,
err
:=
framework
.
WaitForPVClaimBoundPhase
(
c
,
pvcClaims
,
framework
.
ClaimProvisionTimeout
)
pvs
,
err
:=
framework
.
WaitForPVClaimBoundPhase
(
c
,
pvcClaims
,
framework
.
ClaimProvisionTimeout
)
...
@@ -166,6 +163,38 @@ var _ = utils.SIGDescribe("Volume expand", func() {
...
@@ -166,6 +163,38 @@ var _ = utils.SIGDescribe("Volume expand", func() {
pvcConditions
:=
pvc
.
Status
.
Conditions
pvcConditions
:=
pvc
.
Status
.
Conditions
Expect
(
len
(
pvcConditions
))
.
To
(
Equal
(
0
),
"pvc should not have conditions"
)
Expect
(
len
(
pvcConditions
))
.
To
(
Equal
(
0
),
"pvc should not have conditions"
)
})
})
It
(
"should allow expansion of block volumes"
,
func
()
{
pvc
,
storageClassVar
,
err
=
setupFunc
(
true
/*allowExpansion*/
,
true
/*blockVolume*/
)
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
)
Expect
(
len
(
pvs
))
.
To
(
Equal
(
1
))
By
(
"Expanding current pvc"
)
newSize
:=
resource
.
MustParse
(
"6Gi"
)
pvc
,
err
=
expandPVCSize
(
pvc
,
newSize
,
c
)
framework
.
ExpectNoError
(
err
,
"While updating pvc for more size"
)
Expect
(
pvc
)
.
NotTo
(
BeNil
())
pvcSize
:=
pvc
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceStorage
]
if
pvcSize
.
Cmp
(
newSize
)
!=
0
{
framework
.
Failf
(
"error updating pvc size %q"
,
pvc
.
Name
)
}
By
(
"Waiting for cloudprovider resize to finish"
)
err
=
waitForControllerVolumeResize
(
pvc
,
c
,
totalResizeWaitPeriod
)
framework
.
ExpectNoError
(
err
,
"While waiting for pvc resize to finish"
)
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
Expect
(
len
(
pvcConditions
))
.
To
(
Equal
(
0
),
"pvc should not have conditions"
)
})
})
})
func
createStorageClass
(
t
testsuites
.
StorageClassTest
,
ns
string
,
suffix
string
,
c
clientset
.
Interface
)
(
*
storage
.
StorageClass
,
error
)
{
func
createStorageClass
(
t
testsuites
.
StorageClassTest
,
ns
string
,
suffix
string
,
c
clientset
.
Interface
)
(
*
storage
.
StorageClass
,
error
)
{
...
...
test/e2e/storage/volume_provisioning.go
View file @
9e52832c
...
@@ -1034,7 +1034,12 @@ func getClaim(claimSize string, ns string) *v1.PersistentVolumeClaim {
...
@@ -1034,7 +1034,12 @@ func getClaim(claimSize string, ns string) *v1.PersistentVolumeClaim {
}
}
func
newClaim
(
t
testsuites
.
StorageClassTest
,
ns
,
suffix
string
)
*
v1
.
PersistentVolumeClaim
{
func
newClaim
(
t
testsuites
.
StorageClassTest
,
ns
,
suffix
string
)
*
v1
.
PersistentVolumeClaim
{
return
getClaim
(
t
.
ClaimSize
,
ns
)
claim
:=
getClaim
(
t
.
ClaimSize
,
ns
)
if
t
.
VolumeMode
==
v1
.
PersistentVolumeBlock
{
blockVolumeMode
:=
v1
.
PersistentVolumeBlock
claim
.
Spec
.
VolumeMode
=
&
blockVolumeMode
}
return
claim
}
}
func
getDefaultPluginName
()
string
{
func
getDefaultPluginName
()
string
{
...
...
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