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
12d407da
Commit
12d407da
authored
Feb 03, 2016
by
Justin Santa Barbara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AWS EBS: Remove copied-and-pasted udevadm code
This is in GCE to deal with a GCE specific issue; there's no reason to believe we need the same logic on AWS.
parent
f61a5d04
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
62 deletions
+2
-62
aws_util.go
pkg/volume/aws_ebs/aws_util.go
+2
-62
No files found.
pkg/volume/aws_ebs/aws_util.go
View file @
12d407da
...
@@ -20,13 +20,11 @@ import (
...
@@ -20,13 +20,11 @@ import (
"fmt"
"fmt"
"os"
"os"
"path/filepath"
"path/filepath"
"strings"
"time"
"time"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/cloudprovider/providers/aws"
"k8s.io/kubernetes/pkg/cloudprovider/providers/aws"
"k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/keymutex"
"k8s.io/kubernetes/pkg/util/keymutex"
"k8s.io/kubernetes/pkg/util/runtime"
"k8s.io/kubernetes/pkg/util/runtime"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/sets"
...
@@ -179,7 +177,7 @@ func attachDiskAndVerify(b *awsElasticBlockStoreBuilder, xvdBeforeSet sets.Strin
...
@@ -179,7 +177,7 @@ func attachDiskAndVerify(b *awsElasticBlockStoreBuilder, xvdBeforeSet sets.Strin
devicePaths
:=
getDiskByIdPaths
(
b
.
awsElasticBlockStore
,
devicePath
)
devicePaths
:=
getDiskByIdPaths
(
b
.
awsElasticBlockStore
,
devicePath
)
for
numChecks
:=
0
;
numChecks
<
maxChecks
;
numChecks
++
{
for
numChecks
:=
0
;
numChecks
<
maxChecks
;
numChecks
++
{
path
,
err
:=
verifyDevicePath
(
devicePaths
,
xvdBeforeSet
)
path
,
err
:=
verifyDevicePath
(
devicePaths
)
if
err
!=
nil
{
if
err
!=
nil
{
// Log error, if any, and continue checking periodically. See issue #11321
// Log error, if any, and continue checking periodically. See issue #11321
glog
.
Errorf
(
"Error verifying EBS Disk (%q) is attached: %v"
,
b
.
volumeID
,
err
)
glog
.
Errorf
(
"Error verifying EBS Disk (%q) is attached: %v"
,
b
.
volumeID
,
err
)
...
@@ -199,12 +197,7 @@ func attachDiskAndVerify(b *awsElasticBlockStoreBuilder, xvdBeforeSet sets.Strin
...
@@ -199,12 +197,7 @@ func attachDiskAndVerify(b *awsElasticBlockStoreBuilder, xvdBeforeSet sets.Strin
}
}
// Returns the first path that exists, or empty string if none exist.
// Returns the first path that exists, or empty string if none exist.
func
verifyDevicePath
(
devicePaths
[]
string
,
xvdBeforeSet
sets
.
String
)
(
string
,
error
)
{
func
verifyDevicePath
(
devicePaths
[]
string
)
(
string
,
error
)
{
if
err
:=
udevadmChangeToNewDrives
(
xvdBeforeSet
);
err
!=
nil
{
// udevadm errors should not block disk detachment, log and continue
glog
.
Errorf
(
"udevadmChangeToNewDrives failed with: %v"
,
err
)
}
for
_
,
path
:=
range
devicePaths
{
for
_
,
path
:=
range
devicePaths
{
if
pathExists
,
err
:=
pathExists
(
path
);
err
!=
nil
{
if
pathExists
,
err
:=
pathExists
(
path
);
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"Error checking if path exists: %v"
,
err
)
return
""
,
fmt
.
Errorf
(
"Error checking if path exists: %v"
,
err
)
...
@@ -289,10 +282,6 @@ func unmountPDAndRemoveGlobalPath(c *awsElasticBlockStoreCleaner) error {
...
@@ -289,10 +282,6 @@ func unmountPDAndRemoveGlobalPath(c *awsElasticBlockStoreCleaner) error {
func
verifyAllPathsRemoved
(
devicePaths
[]
string
)
(
bool
,
error
)
{
func
verifyAllPathsRemoved
(
devicePaths
[]
string
)
(
bool
,
error
)
{
allPathsRemoved
:=
true
allPathsRemoved
:=
true
for
_
,
path
:=
range
devicePaths
{
for
_
,
path
:=
range
devicePaths
{
if
err
:=
udevadmChangeToDrive
(
path
);
err
!=
nil
{
// udevadm errors should not block disk detachment, log and continue
glog
.
Errorf
(
"%v"
,
err
)
}
if
exists
,
err
:=
pathExists
(
path
);
err
!=
nil
{
if
exists
,
err
:=
pathExists
(
path
);
err
!=
nil
{
return
false
,
fmt
.
Errorf
(
"Error checking if path exists: %v"
,
err
)
return
false
,
fmt
.
Errorf
(
"Error checking if path exists: %v"
,
err
)
}
else
{
}
else
{
...
@@ -343,52 +332,3 @@ func getCloudProvider() (*aws.AWSCloud, error) {
...
@@ -343,52 +332,3 @@ func getCloudProvider() (*aws.AWSCloud, error) {
// The conversion must be safe otherwise bug in GetCloudProvider()
// The conversion must be safe otherwise bug in GetCloudProvider()
return
awsCloudProvider
.
(
*
aws
.
AWSCloud
),
nil
return
awsCloudProvider
.
(
*
aws
.
AWSCloud
),
nil
}
}
// TODO: This udev code is copy-and-paste from the gce_pd provider; refactor
// Calls "udevadm trigger --action=change" for newly created "/dev/xvd*" drives (exist only in after set).
// This is workaround for Issue #7972. Once the underlying issue has been resolved, this may be removed.
func
udevadmChangeToNewDrives
(
xvdBeforeSet
sets
.
String
)
error
{
xvdAfter
,
err
:=
filepath
.
Glob
(
diskXVDPattern
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error filepath.Glob(
\"
%s
\"
): %v
\r\n
"
,
diskXVDPattern
,
err
)
}
for
_
,
xvd
:=
range
xvdAfter
{
if
!
xvdBeforeSet
.
Has
(
xvd
)
{
return
udevadmChangeToDrive
(
xvd
)
}
}
return
nil
}
// Calls "udevadm trigger --action=change" on the specified drive.
// drivePath must be the the block device path to trigger on, in the format "/dev/sd*", or a symlink to it.
// This is workaround for Issue #7972. Once the underlying issue has been resolved, this may be removed.
func
udevadmChangeToDrive
(
drivePath
string
)
error
{
glog
.
V
(
5
)
.
Infof
(
"udevadmChangeToDrive: drive=%q"
,
drivePath
)
// Evaluate symlink, if any
drive
,
err
:=
filepath
.
EvalSymlinks
(
drivePath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"udevadmChangeToDrive: filepath.EvalSymlinks(%q) failed with %v."
,
drivePath
,
err
)
}
glog
.
V
(
5
)
.
Infof
(
"udevadmChangeToDrive: symlink path is %q"
,
drive
)
// Check to make sure input is "/dev/xvd*"
if
!
strings
.
Contains
(
drive
,
diskXVDPath
)
{
return
fmt
.
Errorf
(
"udevadmChangeToDrive: expected input in the form
\"
%s
\"
but drive is %q."
,
diskXVDPattern
,
drive
)
}
// Call "udevadm trigger --action=change --property-match=DEVNAME=/dev/sd..."
_
,
err
=
exec
.
New
()
.
Command
(
"udevadm"
,
"trigger"
,
"--action=change"
,
fmt
.
Sprintf
(
"--property-match=DEVNAME=%s"
,
drive
))
.
CombinedOutput
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"udevadmChangeToDrive: udevadm trigger failed for drive %q with %v."
,
drive
,
err
)
}
return
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