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
a709be86
Commit
a709be86
authored
Apr 30, 2018
by
Jan Safranek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return attach error to A/D controller.
WaitForAttach runs on nodes, not in A/D controller.
parent
c5f46f9e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
15 deletions
+29
-15
csi_attacher.go
pkg/volume/csi/csi_attacher.go
+2
-8
csi_attacher_test.go
pkg/volume/csi/csi_attacher_test.go
+27
-7
No files found.
pkg/volume/csi/csi_attacher.go
View file @
a709be86
...
...
@@ -102,17 +102,11 @@ func (c *csiAttacher) Attach(spec *volume.Spec, nodeName types.NodeName) (string
glog
.
V
(
4
)
.
Info
(
log
(
"attachment [%v] for volume [%v] created successfully"
,
attachID
,
csiSource
.
VolumeHandle
))
}
// probe for attachment update here
// NOTE: any error from waiting for attachment is logged only. This is because
// the primary intent of the enclosing method is to create VolumeAttachment.
// DONOT return that error here as it is mitigated in attacher.WaitForAttach.
volAttachmentOK
:=
true
if
_
,
err
:=
c
.
waitForVolumeAttachment
(
csiSource
.
VolumeHandle
,
attachID
,
csiTimeout
);
err
!=
nil
{
volAttachmentOK
=
false
glog
.
Error
(
log
(
"attacher.Attach attempted to wait for attachment to be ready, but failed with: %v"
,
err
))
return
""
,
err
}
glog
.
V
(
4
)
.
Info
(
log
(
"attacher.Attach finished OK with VolumeAttachment
verified=%t: attachment object [%s]"
,
volAttachmentOK
,
attachID
))
glog
.
V
(
4
)
.
Info
(
log
(
"attacher.Attach finished OK with VolumeAttachment
object [%s]"
,
attachID
))
return
attachID
,
nil
}
...
...
pkg/volume/csi/csi_attacher_test.go
View file @
a709be86
...
...
@@ -59,12 +59,13 @@ func makeTestAttachment(attachID, nodeName, pvName string) *storage.VolumeAttach
func
TestAttacherAttach
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
name
string
nodeName
string
driverName
string
volumeName
string
attachID
string
shouldFail
bool
name
string
nodeName
string
driverName
string
volumeName
string
attachID
string
injectAttacherError
bool
shouldFail
bool
}{
{
name
:
"test ok 1"
,
...
...
@@ -104,6 +105,15 @@ func TestAttacherAttach(t *testing.T) {
attachID
:
getAttachmentName
(
"vol02"
,
"driver02"
,
"node02"
),
shouldFail
:
true
,
},
{
name
:
"attacher error"
,
nodeName
:
"node02"
,
driverName
:
"driver02"
,
volumeName
:
"vol02"
,
attachID
:
getAttachmentName
(
"vol02"
,
"driver02"
,
"node02"
),
injectAttacherError
:
true
,
shouldFail
:
true
,
},
}
// attacher loop
...
...
@@ -127,6 +137,9 @@ func TestAttacherAttach(t *testing.T) {
if
!
fail
&&
err
!=
nil
{
t
.
Errorf
(
"expecting no failure, but got err: %v"
,
err
)
}
if
fail
&&
err
==
nil
{
t
.
Errorf
(
"expecting failure, but got no err"
)
}
if
attachID
!=
id
&&
!
fail
{
t
.
Errorf
(
"expecting attachID %v, got %v"
,
id
,
attachID
)
}
...
...
@@ -154,7 +167,14 @@ func TestAttacherAttach(t *testing.T) {
if
attach
==
nil
{
t
.
Logf
(
"attachment not found for id:%v"
,
tc
.
attachID
)
}
else
{
attach
.
Status
.
Attached
=
true
if
tc
.
injectAttacherError
{
attach
.
Status
.
Attached
=
false
attach
.
Status
.
AttachError
=
&
storage
.
VolumeError
{
Message
:
"attacher error"
,
}
}
else
{
attach
.
Status
.
Attached
=
true
}
_
,
err
=
csiAttacher
.
k8s
.
StorageV1beta1
()
.
VolumeAttachments
()
.
Update
(
attach
)
if
err
!=
nil
{
t
.
Error
(
err
)
...
...
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