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
b9606696
Commit
b9606696
authored
Mar 13, 2018
by
mlmhl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return error if get NodeStageSecret and NodePublishSecret failed
parent
a7d6340a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
13 deletions
+22
-13
csi_attacher.go
pkg/volume/csi/csi_attacher.go
+9
-5
csi_mounter.go
pkg/volume/csi/csi_mounter.go
+9
-4
csi_util.go
pkg/volume/csi/csi_util.go
+4
-4
No files found.
pkg/volume/csi/csi_attacher.go
View file @
b9606696
...
...
@@ -318,6 +318,15 @@ func (c *csiAttacher) MountDevice(spec *volume.Spec, devicePath string, deviceMo
}
publishVolumeInfo
:=
attachment
.
Status
.
AttachmentMetadata
nodeStageSecrets
:=
map
[
string
]
string
{}
if
csiSource
.
NodeStageSecretRef
!=
nil
{
nodeStageSecrets
,
err
=
getCredentialsFromSecret
(
c
.
k8s
,
csiSource
.
NodeStageSecretRef
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"fetching NodeStageSecretRef %s/%s failed: %v"
,
csiSource
.
NodeStageSecretRef
.
Namespace
,
csiSource
.
NodeStageSecretRef
.
Name
,
err
)
}
}
// create target_dir before call to NodeStageVolume
if
err
:=
os
.
MkdirAll
(
deviceMountPath
,
0750
);
err
!=
nil
{
glog
.
Error
(
log
(
"attacher.MountDevice failed to create dir %#v: %v"
,
deviceMountPath
,
err
))
...
...
@@ -336,11 +345,6 @@ func (c *csiAttacher) MountDevice(spec *volume.Spec, devicePath string, deviceMo
fsType
=
defaultFSType
}
nodeStageSecrets
:=
map
[
string
]
string
{}
if
csiSource
.
NodeStageSecretRef
!=
nil
{
nodeStageSecrets
=
getCredentialsFromSecret
(
c
.
k8s
,
csiSource
.
NodeStageSecretRef
)
}
err
=
csi
.
NodeStageVolume
(
ctx
,
csiSource
.
VolumeHandle
,
publishVolumeInfo
,
...
...
pkg/volume/csi/csi_mounter.go
View file @
b9606696
...
...
@@ -153,6 +153,15 @@ func (c *csiMountMgr) SetUpAt(dir string, fsGroup *int64) error {
attribs
:=
csiSource
.
VolumeAttributes
nodePublishSecrets
:=
map
[
string
]
string
{}
if
csiSource
.
NodePublishSecretRef
!=
nil
{
nodePublishSecrets
,
err
=
getCredentialsFromSecret
(
c
.
k8s
,
csiSource
.
NodePublishSecretRef
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"fetching NodePublishSecretRef %s/%s failed: %v"
,
csiSource
.
NodePublishSecretRef
.
Namespace
,
csiSource
.
NodePublishSecretRef
.
Name
,
err
)
}
}
// create target_dir before call to NodePublish
if
err
:=
os
.
MkdirAll
(
dir
,
0750
);
err
!=
nil
{
glog
.
Error
(
log
(
"mouter.SetUpAt failed to create dir %#v: %v"
,
dir
,
err
))
...
...
@@ -188,10 +197,6 @@ func (c *csiMountMgr) SetUpAt(dir string, fsGroup *int64) error {
if
len
(
fsType
)
==
0
{
fsType
=
defaultFSType
}
nodePublishSecrets
:=
map
[
string
]
string
{}
if
csiSource
.
NodePublishSecretRef
!=
nil
{
nodePublishSecrets
=
getCredentialsFromSecret
(
c
.
k8s
,
csiSource
.
NodePublishSecretRef
)
}
err
=
csi
.
NodePublishVolume
(
ctx
,
c
.
volumeID
,
...
...
pkg/volume/csi/csi_util.go
View file @
b9606696
...
...
@@ -23,16 +23,16 @@ import (
"k8s.io/client-go/kubernetes"
)
func
getCredentialsFromSecret
(
k8s
kubernetes
.
Interface
,
secretRef
*
api
.
SecretReference
)
map
[
string
]
string
{
func
getCredentialsFromSecret
(
k8s
kubernetes
.
Interface
,
secretRef
*
api
.
SecretReference
)
(
map
[
string
]
string
,
error
)
{
credentials
:=
map
[
string
]
string
{}
secret
,
err
:=
k8s
.
CoreV1
()
.
Secrets
(
secretRef
.
Namespace
)
.
Get
(
secretRef
.
Name
,
meta
.
GetOptions
{})
if
err
!=
nil
{
glog
.
Warning
f
(
"failed to find the secret %s in the namespace %s with error: %v
\n
"
,
secretRef
.
Name
,
secretRef
.
Namespace
,
err
)
return
credentials
glog
.
Error
f
(
"failed to find the secret %s in the namespace %s with error: %v
\n
"
,
secretRef
.
Name
,
secretRef
.
Namespace
,
err
)
return
credentials
,
err
}
for
key
,
value
:=
range
secret
.
Data
{
credentials
[
key
]
=
string
(
value
)
}
return
credentials
return
credentials
,
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