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
89fd358c
Commit
89fd358c
authored
Jul 22, 2016
by
saadali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Assume volume detached if node doesn't exist
Fixes #29358
parent
a6b8aa99
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
8 deletions
+46
-8
aws.go
pkg/cloudprovider/providers/aws/aws.go
+24
-6
gce.go
pkg/cloudprovider/providers/gce/gce.go
+18
-0
node_status_updater.go
.../volume/attachdetach/statusupdater/node_status_updater.go
+4
-2
No files found.
pkg/cloudprovider/providers/aws/aws.go
View file @
89fd358c
...
@@ -812,7 +812,7 @@ func (c *Cloud) NodeAddresses(name string) ([]api.NodeAddress, error) {
...
@@ -812,7 +812,7 @@ func (c *Cloud) NodeAddresses(name string) ([]api.NodeAddress, error) {
}
}
instance
,
err
:=
c
.
getInstanceByNodeName
(
name
)
instance
,
err
:=
c
.
getInstanceByNodeName
(
name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
fmt
.
Errorf
(
"getInstanceByNodeName failed for %q with %v"
,
name
,
err
)
}
}
addresses
:=
[]
api
.
NodeAddress
{}
addresses
:=
[]
api
.
NodeAddress
{}
...
@@ -869,7 +869,7 @@ func (c *Cloud) InstanceID(name string) (string, error) {
...
@@ -869,7 +869,7 @@ func (c *Cloud) InstanceID(name string) (string, error) {
}
}
inst
,
err
:=
c
.
getInstanceByNodeName
(
name
)
inst
,
err
:=
c
.
getInstanceByNodeName
(
name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
fmt
.
Errorf
(
"getInstanceByNodeName failed for %q with %v"
,
name
,
err
)
}
}
return
"/"
+
orEmpty
(
inst
.
Placement
.
AvailabilityZone
)
+
"/"
+
orEmpty
(
inst
.
InstanceId
),
nil
return
"/"
+
orEmpty
(
inst
.
Placement
.
AvailabilityZone
)
+
"/"
+
orEmpty
(
inst
.
InstanceId
),
nil
}
}
...
@@ -881,7 +881,7 @@ func (c *Cloud) InstanceType(name string) (string, error) {
...
@@ -881,7 +881,7 @@ func (c *Cloud) InstanceType(name string) (string, error) {
}
}
inst
,
err
:=
c
.
getInstanceByNodeName
(
name
)
inst
,
err
:=
c
.
getInstanceByNodeName
(
name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
fmt
.
Errorf
(
"getInstanceByNodeName failed for %q with %v"
,
name
,
err
)
}
}
return
orEmpty
(
inst
.
InstanceType
),
nil
return
orEmpty
(
inst
.
InstanceType
),
nil
}
}
...
@@ -1336,7 +1336,7 @@ func (c *Cloud) getAwsInstance(nodeName string) (*awsInstance, error) {
...
@@ -1336,7 +1336,7 @@ func (c *Cloud) getAwsInstance(nodeName string) (*awsInstance, error) {
}
else
{
}
else
{
instance
,
err
:=
c
.
getInstanceByNodeName
(
nodeName
)
instance
,
err
:=
c
.
getInstanceByNodeName
(
nodeName
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error finding instance %s: %v"
,
nodeName
,
err
)
return
nil
,
err
}
}
awsInstance
=
newAWSInstance
(
c
.
ec2
,
instance
)
awsInstance
=
newAWSInstance
(
c
.
ec2
,
instance
)
...
@@ -1354,7 +1354,7 @@ func (c *Cloud) AttachDisk(diskName string, instanceName string, readOnly bool)
...
@@ -1354,7 +1354,7 @@ func (c *Cloud) AttachDisk(diskName string, instanceName string, readOnly bool)
awsInstance
,
err
:=
c
.
getAwsInstance
(
instanceName
)
awsInstance
,
err
:=
c
.
getAwsInstance
(
instanceName
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
fmt
.
Errorf
(
"error finding instance %s: %v"
,
instanceName
,
err
)
}
}
if
readOnly
{
if
readOnly
{
...
@@ -1419,6 +1419,15 @@ func (c *Cloud) DetachDisk(diskName string, instanceName string) (string, error)
...
@@ -1419,6 +1419,15 @@ func (c *Cloud) DetachDisk(diskName string, instanceName string) (string, error)
awsInstance
,
err
:=
c
.
getAwsInstance
(
instanceName
)
awsInstance
,
err
:=
c
.
getAwsInstance
(
instanceName
)
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
cloudprovider
.
InstanceNotFound
{
// If instance no longer exists, safe to assume volume is not attached.
glog
.
Warningf
(
"Instance %q does not exist. DetachDisk will assume disk %q is not attached to it."
,
instanceName
,
diskName
)
return
""
,
nil
}
return
""
,
err
return
""
,
err
}
}
...
@@ -1562,6 +1571,15 @@ func (c *Cloud) GetDiskPath(volumeName string) (string, error) {
...
@@ -1562,6 +1571,15 @@ func (c *Cloud) GetDiskPath(volumeName string) (string, error) {
func
(
c
*
Cloud
)
DiskIsAttached
(
diskName
,
instanceID
string
)
(
bool
,
error
)
{
func
(
c
*
Cloud
)
DiskIsAttached
(
diskName
,
instanceID
string
)
(
bool
,
error
)
{
awsInstance
,
err
:=
c
.
getAwsInstance
(
instanceID
)
awsInstance
,
err
:=
c
.
getAwsInstance
(
instanceID
)
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
cloudprovider
.
InstanceNotFound
{
// If instance no longer exists, safe to assume volume is not attached.
glog
.
Warningf
(
"Instance %q does not exist. DiskIsAttached will assume disk %q is not attached to it."
,
instanceID
,
diskName
)
return
false
,
nil
}
return
false
,
err
return
false
,
err
}
}
...
@@ -2918,7 +2936,7 @@ func (c *Cloud) findInstanceByNodeName(nodeName string) (*ec2.Instance, error) {
...
@@ -2918,7 +2936,7 @@ func (c *Cloud) findInstanceByNodeName(nodeName string) (*ec2.Instance, error) {
func
(
c
*
Cloud
)
getInstanceByNodeName
(
nodeName
string
)
(
*
ec2
.
Instance
,
error
)
{
func
(
c
*
Cloud
)
getInstanceByNodeName
(
nodeName
string
)
(
*
ec2
.
Instance
,
error
)
{
instance
,
err
:=
c
.
findInstanceByNodeName
(
nodeName
)
instance
,
err
:=
c
.
findInstanceByNodeName
(
nodeName
)
if
err
==
nil
&&
instance
==
nil
{
if
err
==
nil
&&
instance
==
nil
{
return
nil
,
fmt
.
Errorf
(
"no instances found for name: %s"
,
nodeName
)
return
nil
,
cloudprovider
.
InstanceNotFound
}
}
return
instance
,
err
return
instance
,
err
}
}
...
...
pkg/cloudprovider/providers/gce/gce.go
View file @
89fd358c
...
@@ -2367,6 +2367,15 @@ func (gce *GCECloud) AttachDisk(diskName, instanceID string, readOnly bool) erro
...
@@ -2367,6 +2367,15 @@ func (gce *GCECloud) AttachDisk(diskName, instanceID string, readOnly bool) erro
func
(
gce
*
GCECloud
)
DetachDisk
(
devicePath
,
instanceID
string
)
error
{
func
(
gce
*
GCECloud
)
DetachDisk
(
devicePath
,
instanceID
string
)
error
{
inst
,
err
:=
gce
.
getInstanceByName
(
instanceID
)
inst
,
err
:=
gce
.
getInstanceByName
(
instanceID
)
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
cloudprovider
.
InstanceNotFound
{
// If instance no longer exists, safe to assume volume is not attached.
glog
.
Warningf
(
"Instance %q does not exist. DetachDisk will assume PD %q is not attached to it."
,
instanceID
,
devicePath
)
return
nil
}
return
fmt
.
Errorf
(
"error getting instance %q"
,
instanceID
)
return
fmt
.
Errorf
(
"error getting instance %q"
,
instanceID
)
}
}
...
@@ -2381,6 +2390,15 @@ func (gce *GCECloud) DetachDisk(devicePath, instanceID string) error {
...
@@ -2381,6 +2390,15 @@ func (gce *GCECloud) DetachDisk(devicePath, instanceID string) error {
func
(
gce
*
GCECloud
)
DiskIsAttached
(
diskName
,
instanceID
string
)
(
bool
,
error
)
{
func
(
gce
*
GCECloud
)
DiskIsAttached
(
diskName
,
instanceID
string
)
(
bool
,
error
)
{
instance
,
err
:=
gce
.
getInstanceByName
(
instanceID
)
instance
,
err
:=
gce
.
getInstanceByName
(
instanceID
)
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
cloudprovider
.
InstanceNotFound
{
// If instance no longer exists, safe to assume volume is not attached.
glog
.
Warningf
(
"Instance %q does not exist. DiskIsAttached will assume PD %q is not attached to it."
,
instanceID
,
diskName
)
return
false
,
nil
}
return
false
,
err
return
false
,
err
}
}
...
...
pkg/controller/volume/attachdetach/statusupdater/node_status_updater.go
View file @
89fd358c
...
@@ -62,10 +62,12 @@ func (nsu *nodeStatusUpdater) UpdateNodeStatuses() error {
...
@@ -62,10 +62,12 @@ func (nsu *nodeStatusUpdater) UpdateNodeStatuses() error {
for
nodeName
,
attachedVolumes
:=
range
nodesToUpdate
{
for
nodeName
,
attachedVolumes
:=
range
nodesToUpdate
{
nodeObj
,
exists
,
err
:=
nsu
.
nodeInformer
.
GetStore
()
.
GetByKey
(
nodeName
)
nodeObj
,
exists
,
err
:=
nsu
.
nodeInformer
.
GetStore
()
.
GetByKey
(
nodeName
)
if
nodeObj
==
nil
||
!
exists
||
err
!=
nil
{
if
nodeObj
==
nil
||
!
exists
||
err
!=
nil
{
return
fmt
.
Errorf
(
// If node does not exist, its status cannot be updated, log error and move on.
"failed to find node %q in NodeInformer cache. %v"
,
glog
.
Warningf
(
"Could not update node status. Failed to find node %q in NodeInformer cache. %v"
,
nodeName
,
nodeName
,
err
)
err
)
return
nil
}
}
node
,
ok
:=
nodeObj
.
(
*
api
.
Node
)
node
,
ok
:=
nodeObj
.
(
*
api
.
Node
)
...
...
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