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
fc6443ce
Commit
fc6443ce
authored
Dec 08, 2017
by
Humble Chirammal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add volID based delete() and resize() if volID is available in pv spec.
Signed-off-by:
Humble Chirammal
<
hchiramm@redhat.com
>
parent
95552b07
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
glusterfs.go
pkg/volume/glusterfs/glusterfs.go
+30
-3
No files found.
pkg/volume/glusterfs/glusterfs.go
View file @
fc6443ce
...
...
@@ -596,8 +596,13 @@ func (d *glusterfsVolumeDeleter) getGid() (int, bool, error) {
func
(
d
*
glusterfsVolumeDeleter
)
Delete
()
error
{
glog
.
V
(
2
)
.
Infof
(
"delete volume: %s "
,
d
.
glusterfsMounter
.
path
)
volumeName
:=
d
.
glusterfsMounter
.
path
volumeID
:=
dstrings
.
TrimPrefix
(
volumeName
,
volPrefix
)
volumeID
,
err
:=
getVolumeID
(
d
.
spec
,
volumeName
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to get volumeID, err: %v"
,
err
)
}
class
,
err
:=
volutil
.
GetClassForVolume
(
d
.
plugin
.
host
.
GetKubeClient
(),
d
.
spec
)
if
err
!=
nil
{
return
err
...
...
@@ -1048,13 +1053,35 @@ func parseClassParameters(params map[string]string, kubeClient clientset.Interfa
return
&
cfg
,
nil
}
// getVolumeID returns volumeID from the PV or volumename.
func
getVolumeID
(
pv
*
v1
.
PersistentVolume
,
volumeName
string
)
(
string
,
error
)
{
volumeID
:=
""
// Get volID from pvspec if available, else fill it from volumename.
if
pv
!=
nil
{
if
pv
.
Annotations
[
"VolID"
]
!=
""
{
volumeID
=
pv
.
Annotations
[
"VolID"
]
}
else
{
volumeID
=
dstrings
.
TrimPrefix
(
volumeName
,
volPrefix
)
}
}
else
{
return
volumeID
,
fmt
.
Errorf
(
"provided PV spec is nil"
)
}
if
volumeID
==
""
{
return
volumeID
,
fmt
.
Errorf
(
"volume ID is empty"
)
}
return
volumeID
,
nil
}
func
(
plugin
*
glusterfsPlugin
)
ExpandVolumeDevice
(
spec
*
volume
.
Spec
,
newSize
resource
.
Quantity
,
oldSize
resource
.
Quantity
)
(
resource
.
Quantity
,
error
)
{
pvSpec
:=
spec
.
PersistentVolume
.
Spec
glog
.
V
(
2
)
.
Infof
(
"Request to expand volume: %s "
,
pvSpec
.
Glusterfs
.
Path
)
volumeName
:=
pvSpec
.
Glusterfs
.
Path
volumeID
,
err
:=
getVolumeID
(
spec
.
PersistentVolume
,
volumeName
)
// Fetch the volume for expansion.
volumeID
:=
dstrings
.
TrimPrefix
(
volumeName
,
volPrefix
)
if
err
!=
nil
{
return
oldSize
,
fmt
.
Errorf
(
"failed to get volumeID, err: %v"
,
err
)
}
//Get details of SC.
class
,
err
:=
volutil
.
GetClassForVolume
(
plugin
.
host
.
GetKubeClient
(),
spec
.
PersistentVolume
)
...
...
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