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
fa1d6f38
Commit
fa1d6f38
authored
Dec 21, 2016
by
Angus Lees
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forcibly detach an attached volume before attaching elsewhere
Fixes #33288 Co-Authored-By: @Rotwang
parent
e843f77c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
openstack_volumes.go
pkg/cloudprovider/providers/openstack/openstack_volumes.go
+8
-5
attacher.go
pkg/volume/cinder/attacher.go
+1
-1
No files found.
pkg/cloudprovider/providers/openstack/openstack_volumes.go
View file @
fa1d6f38
...
@@ -52,18 +52,21 @@ func (os *OpenStack) AttachDisk(instanceID string, diskName string) (string, err
...
@@ -52,18 +52,21 @@ func (os *OpenStack) AttachDisk(instanceID string, diskName string) (string, err
if
instanceID
==
disk
.
Attachments
[
0
][
"server_id"
]
{
if
instanceID
==
disk
.
Attachments
[
0
][
"server_id"
]
{
glog
.
V
(
4
)
.
Infof
(
"Disk: %q is already attached to compute: %q"
,
diskName
,
instanceID
)
glog
.
V
(
4
)
.
Infof
(
"Disk: %q is already attached to compute: %q"
,
diskName
,
instanceID
)
return
disk
.
ID
,
nil
return
disk
.
ID
,
nil
}
else
{
}
errMsg
:=
fmt
.
Sprintf
(
"Disk %q is attached to a different compute: %q, should be detached before proceeding"
,
diskName
,
disk
.
Attachments
[
0
][
"server_id"
])
glog
.
Errorf
(
errMsg
)
glog
.
V
(
2
)
.
Infof
(
"Disk %q is attached to a different compute (%q), detaching"
,
diskName
,
disk
.
Attachments
[
0
][
"server_id"
])
return
""
,
errors
.
New
(
errMsg
)
err
=
os
.
DetachDisk
(
fmt
.
Sprintf
(
"%s"
,
disk
.
Attachments
[
0
][
"server_id"
]),
diskName
)
if
err
!=
nil
{
return
""
,
err
}
}
}
}
// add read only flag here if possible spothanis
// add read only flag here if possible spothanis
_
,
err
=
volumeattach
.
Create
(
cClient
,
instanceID
,
&
volumeattach
.
CreateOpts
{
_
,
err
=
volumeattach
.
Create
(
cClient
,
instanceID
,
&
volumeattach
.
CreateOpts
{
VolumeID
:
disk
.
ID
,
VolumeID
:
disk
.
ID
,
})
.
Extract
()
})
.
Extract
()
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to attach %s volume to %s compute
"
,
diskName
,
instanceID
)
glog
.
Errorf
(
"Failed to attach %s volume to %s compute
: %v"
,
diskName
,
instanceID
,
err
)
return
""
,
err
return
""
,
err
}
}
glog
.
V
(
2
)
.
Infof
(
"Successfully attached %s volume to %s compute"
,
diskName
,
instanceID
)
glog
.
V
(
2
)
.
Infof
(
"Successfully attached %s volume to %s compute"
,
diskName
,
instanceID
)
...
...
pkg/volume/cinder/attacher.go
View file @
fa1d6f38
...
@@ -177,7 +177,7 @@ func (attacher *cinderDiskAttacher) WaitForAttach(spec *volume.Spec, devicePath
...
@@ -177,7 +177,7 @@ func (attacher *cinderDiskAttacher) WaitForAttach(spec *volume.Spec, devicePath
return
devicePath
,
nil
return
devicePath
,
nil
}
else
{
}
else
{
// Log an error, and continue checking periodically
// Log an error, and continue checking periodically
glog
.
Errorf
(
"Error: could not find attached Cinder disk %q
: %v"
,
volumeID
,
err
)
glog
.
Errorf
(
"Error: could not find attached Cinder disk %q
(path: %q): %v"
,
volumeID
,
devicePath
,
err
)
}
}
case
<-
timer
.
C
:
case
<-
timer
.
C
:
return
""
,
fmt
.
Errorf
(
"Could not find attached Cinder disk %q. Timeout waiting for mount paths to be created."
,
volumeID
)
return
""
,
fmt
.
Errorf
(
"Could not find attached Cinder disk %q. Timeout waiting for mount paths to be created."
,
volumeID
)
...
...
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