Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nfs-subdir-external-provisioner
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rancher商店
nfs-subdir-external-provisioner
Commits
23794089
Unverified
Commit
23794089
authored
Mar 07, 2022
by
Kubernetes Prow Robot
Committed by
GitHub
Mar 07, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #176 from humblec/new
Handle error and also correct error strings.
parents
69979f8f
7c23a7dd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
15 deletions
+19
-15
OWNERS
OWNERS
+4
-3
provisioner.go
cmd/nfs-subdir-external-provisioner/provisioner.go
+15
-12
No files found.
OWNERS
View file @
23794089
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- wongma7
- ashishranjan738
- humblec
- jackielii
- jsafrane
- kmova
- jackielii
- ashishranjan738
- yonatankahana
- wongma7
cmd/nfs-subdir-external-provisioner/provisioner.go
View file @
23794089
...
...
@@ -62,13 +62,14 @@ func (meta *pvcMetadata) stringParser(str string) string {
for
_
,
r
:=
range
result
{
switch
r
[
2
]
{
case
"labels"
:
str
=
strings
.
Replace
(
str
,
r
[
0
],
meta
.
labels
[
r
[
3
]],
-
1
)
str
=
strings
.
Replace
All
(
str
,
r
[
0
],
meta
.
labels
[
r
[
3
]]
)
case
"annotations"
:
str
=
strings
.
Replace
(
str
,
r
[
0
],
meta
.
annotations
[
r
[
3
]],
-
1
)
str
=
strings
.
Replace
All
(
str
,
r
[
0
],
meta
.
annotations
[
r
[
3
]]
)
default
:
str
=
strings
.
Replace
(
str
,
r
[
0
],
meta
.
data
[
r
[
1
]],
-
1
)
str
=
strings
.
Replace
All
(
str
,
r
[
0
],
meta
.
data
[
r
[
1
]]
)
}
}
return
str
}
...
...
@@ -111,10 +112,13 @@ func (p *nfsProvisioner) Provision(ctx context.Context, options controller.Provi
}
glog
.
V
(
4
)
.
Infof
(
"creating path %s"
,
fullPath
)
if
err
:=
os
.
MkdirAll
(
fullPath
,
0777
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
fullPath
,
0
o
777
);
err
!=
nil
{
return
nil
,
controller
.
ProvisioningFinished
,
errors
.
New
(
"unable to create directory to provision new pv: "
+
err
.
Error
())
}
os
.
Chmod
(
fullPath
,
0777
)
err
:=
os
.
Chmod
(
fullPath
,
0
o777
)
if
err
!=
nil
{
return
nil
,
""
,
err
}
pv
:=
&
v1
.
PersistentVolume
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
...
@@ -155,14 +159,12 @@ func (p *nfsProvisioner) Delete(ctx context.Context, volume *v1.PersistentVolume
}
// Determine if the "onDelete" parameter exists.
// If it exists and has a
delete
value, delete the directory.
// If it exists and has a
retain
value, safe the directory.
// If it exists and has a
`delete`
value, delete the directory.
// If it exists and has a
`retain`
value, safe the directory.
onDelete
:=
storageClass
.
Parameters
[
"onDelete"
]
switch
onDelete
{
case
"delete"
:
return
os
.
RemoveAll
(
oldPath
)
case
"retain"
:
return
nil
}
...
...
@@ -186,19 +188,20 @@ func (p *nfsProvisioner) Delete(ctx context.Context, volume *v1.PersistentVolume
return
os
.
Rename
(
oldPath
,
archivePath
)
}
// getClassForVolume returns StorageClass
// getClassForVolume returns StorageClass
.
func
(
p
*
nfsProvisioner
)
getClassForVolume
(
ctx
context
.
Context
,
pv
*
v1
.
PersistentVolume
)
(
*
storage
.
StorageClass
,
error
)
{
if
p
.
client
==
nil
{
return
nil
,
fmt
.
Errorf
(
"
C
annot get kube client"
)
return
nil
,
fmt
.
Errorf
(
"
c
annot get kube client"
)
}
className
:=
helper
.
GetPersistentVolumeClass
(
pv
)
if
className
==
""
{
return
nil
,
fmt
.
Errorf
(
"
V
olume has no storage class"
)
return
nil
,
fmt
.
Errorf
(
"
v
olume has no storage class"
)
}
class
,
err
:=
p
.
client
.
StorageV1
()
.
StorageClasses
()
.
Get
(
ctx
,
className
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
nil
,
err
}
return
class
,
nil
}
...
...
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