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
933cf60a
Commit
933cf60a
authored
Apr 09, 2015
by
Justin Santa Barbara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Style: volumeId -> volumeID
parent
98c9ebbc
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
63 additions
and
63 deletions
+63
-63
types.go
pkg/api/types.go
+1
-1
types.go
pkg/api/v1beta1/types.go
+1
-1
types.go
pkg/api/v1beta2/types.go
+1
-1
types.go
pkg/api/v1beta3/types.go
+1
-1
validation.go
pkg/api/validation/validation.go
+2
-2
aws.go
pkg/cloudprovider/aws/aws.go
+24
-24
aws_test.go
pkg/cloudprovider/aws/aws_test.go
+4
-4
predicates.go
pkg/scheduler/predicates.go
+2
-2
predicates_test.go
pkg/scheduler/predicates_test.go
+2
-2
aws_pd.go
pkg/volume/aws_pd/aws_pd.go
+16
-16
aws_pd_test.go
pkg/volume/aws_pd/aws_pd_test.go
+3
-3
aws_util.go
pkg/volume/aws_pd/aws_util.go
+5
-5
pd.go
test/e2e/pd.go
+1
-1
No files found.
pkg/api/types.go
View file @
933cf60a
...
@@ -407,7 +407,7 @@ type ISCSIVolumeSource struct {
...
@@ -407,7 +407,7 @@ type ISCSIVolumeSource struct {
// A AWS EBS disk can only be mounted as read/write once.
// A AWS EBS disk can only be mounted as read/write once.
type
AWSElasticBlockStoreVolumeSource
struct
{
type
AWSElasticBlockStoreVolumeSource
struct
{
// Unique id of the persistent disk resource. Used to identify the disk in AWS
// Unique id of the persistent disk resource. Used to identify the disk in AWS
VolumeI
d
string
`json:"volumeId
"`
VolumeI
D
string
`json:"volumeID
"`
// Required: Filesystem type to mount.
// Required: Filesystem type to mount.
// Must be a filesystem type supported by the host operating system.
// Must be a filesystem type supported by the host operating system.
// Ex. "ext4", "xfs", "ntfs"
// Ex. "ext4", "xfs", "ntfs"
...
...
pkg/api/v1beta1/types.go
View file @
933cf60a
...
@@ -315,7 +315,7 @@ type ISCSIVolumeSource struct {
...
@@ -315,7 +315,7 @@ type ISCSIVolumeSource struct {
// A AWS PD can only be mounted on a single machine.
// A AWS PD can only be mounted on a single machine.
type
AWSElasticBlockStoreVolumeSource
struct
{
type
AWSElasticBlockStoreVolumeSource
struct
{
// Unique id of the PD resource. Used to identify the disk in AWS
// Unique id of the PD resource. Used to identify the disk in AWS
VolumeI
d
string
`json:"volumeId
" description:"unique id of the PD resource in AWS"`
VolumeI
D
string
`json:"volumeID
" description:"unique id of the PD resource in AWS"`
// Required: Filesystem type to mount.
// Required: Filesystem type to mount.
// Must be a filesystem type supported by the host operating system.
// Must be a filesystem type supported by the host operating system.
// Ex. "ext4", "xfs", "ntfs"
// Ex. "ext4", "xfs", "ntfs"
...
...
pkg/api/v1beta2/types.go
View file @
933cf60a
...
@@ -297,7 +297,7 @@ type GCEPersistentDiskVolumeSource struct {
...
@@ -297,7 +297,7 @@ type GCEPersistentDiskVolumeSource struct {
// A AWS PD can only be mounted on a single machine.
// A AWS PD can only be mounted on a single machine.
type
AWSElasticBlockStoreVolumeSource
struct
{
type
AWSElasticBlockStoreVolumeSource
struct
{
// Unique id of the PD resource. Used to identify the disk in AWS
// Unique id of the PD resource. Used to identify the disk in AWS
VolumeI
d
string
`json:"volumeId
" description:"unique id of the PD resource in AWS"`
VolumeI
D
string
`json:"volumeID
" description:"unique id of the PD resource in AWS"`
// Required: Filesystem type to mount.
// Required: Filesystem type to mount.
// Must be a filesystem type supported by the host operating system.
// Must be a filesystem type supported by the host operating system.
// Ex. "ext4", "xfs", "ntfs"
// Ex. "ext4", "xfs", "ntfs"
...
...
pkg/api/v1beta3/types.go
View file @
933cf60a
...
@@ -413,7 +413,7 @@ type GCEPersistentDiskVolumeSource struct {
...
@@ -413,7 +413,7 @@ type GCEPersistentDiskVolumeSource struct {
// A AWS PD can only be mounted on a single machine.
// A AWS PD can only be mounted on a single machine.
type
AWSElasticBlockStoreVolumeSource
struct
{
type
AWSElasticBlockStoreVolumeSource
struct
{
// Unique id of the PD resource. Used to identify the disk in AWS
// Unique id of the PD resource. Used to identify the disk in AWS
VolumeI
d
string
`json:"volumeId
" description:"unique id of the PD resource in AWS"`
VolumeI
D
string
`json:"volumeID
" description:"unique id of the PD resource in AWS"`
// Required: Filesystem type to mount.
// Required: Filesystem type to mount.
// Must be a filesystem type supported by the host operating system.
// Must be a filesystem type supported by the host operating system.
// Ex. "ext4", "xfs", "ntfs"
// Ex. "ext4", "xfs", "ntfs"
...
...
pkg/api/validation/validation.go
View file @
933cf60a
...
@@ -374,8 +374,8 @@ func validateGCEPersistentDiskVolumeSource(PD *api.GCEPersistentDiskVolumeSource
...
@@ -374,8 +374,8 @@ func validateGCEPersistentDiskVolumeSource(PD *api.GCEPersistentDiskVolumeSource
func
validateAWSElasticBlockStoreVolumeSource
(
PD
*
api
.
AWSElasticBlockStoreVolumeSource
)
errs
.
ValidationErrorList
{
func
validateAWSElasticBlockStoreVolumeSource
(
PD
*
api
.
AWSElasticBlockStoreVolumeSource
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
if
PD
.
VolumeI
d
==
""
{
if
PD
.
VolumeI
D
==
""
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"volumeI
d
"
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"volumeI
D
"
))
}
}
if
PD
.
FSType
==
""
{
if
PD
.
FSType
==
""
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"fsType"
))
allErrs
=
append
(
allErrs
,
errs
.
NewFieldRequired
(
"fsType"
))
...
...
pkg/cloudprovider/aws/aws.go
View file @
933cf60a
...
@@ -44,16 +44,16 @@ type EC2 interface {
...
@@ -44,16 +44,16 @@ type EC2 interface {
Instances
(
instIds
[]
string
,
filter
*
ec2InstanceFilter
)
(
resp
*
ec2
.
InstancesResp
,
err
error
)
Instances
(
instIds
[]
string
,
filter
*
ec2InstanceFilter
)
(
resp
*
ec2
.
InstancesResp
,
err
error
)
// Attach a volume to an instance
// Attach a volume to an instance
AttachVolume
(
volumeI
d
string
,
instanceId
string
,
mountDevice
string
)
(
resp
*
ec2
.
AttachVolumeResp
,
err
error
)
AttachVolume
(
volumeI
D
string
,
instanceId
string
,
mountDevice
string
)
(
resp
*
ec2
.
AttachVolumeResp
,
err
error
)
// Detach a volume from whatever instance it is attached to
// Detach a volume from whatever instance it is attached to
// TODO: We should specify the InstanceID and the Device, for safety
// TODO: We should specify the InstanceID and the Device, for safety
DetachVolume
(
volumeI
d
string
)
(
resp
*
ec2
.
SimpleResp
,
err
error
)
DetachVolume
(
volumeI
D
string
)
(
resp
*
ec2
.
SimpleResp
,
err
error
)
// Lists volumes
// Lists volumes
Volumes
(
volumeI
d
s
[]
string
,
filter
*
ec2
.
Filter
)
(
resp
*
ec2
.
VolumesResp
,
err
error
)
Volumes
(
volumeI
D
s
[]
string
,
filter
*
ec2
.
Filter
)
(
resp
*
ec2
.
VolumesResp
,
err
error
)
// Create an EBS volume
// Create an EBS volume
CreateVolume
(
request
*
ec2
.
CreateVolume
)
(
resp
*
ec2
.
CreateVolumeResp
,
err
error
)
CreateVolume
(
request
*
ec2
.
CreateVolume
)
(
resp
*
ec2
.
CreateVolumeResp
,
err
error
)
// Delete an EBS volume
// Delete an EBS volume
DeleteVolume
(
volumeI
d
string
)
(
resp
*
ec2
.
SimpleResp
,
err
error
)
DeleteVolume
(
volumeI
D
string
)
(
resp
*
ec2
.
SimpleResp
,
err
error
)
}
}
// Abstraction over the AWS metadata service
// Abstraction over the AWS metadata service
...
@@ -147,24 +147,24 @@ func (self *goamzMetadata) GetMetaData(key string) ([]byte, error) {
...
@@ -147,24 +147,24 @@ func (self *goamzMetadata) GetMetaData(key string) ([]byte, error) {
type
AuthFunc
func
()
(
auth
aws
.
Auth
,
err
error
)
type
AuthFunc
func
()
(
auth
aws
.
Auth
,
err
error
)
func
(
s
*
goamzEC2
)
AttachVolume
(
volumeI
d
string
,
instanceId
string
,
device
string
)
(
resp
*
ec2
.
AttachVolumeResp
,
err
error
)
{
func
(
s
*
goamzEC2
)
AttachVolume
(
volumeI
D
string
,
instanceId
string
,
device
string
)
(
resp
*
ec2
.
AttachVolumeResp
,
err
error
)
{
return
s
.
ec2
.
AttachVolume
(
volumeI
d
,
instanceId
,
device
)
return
s
.
ec2
.
AttachVolume
(
volumeI
D
,
instanceId
,
device
)
}
}
func
(
s
*
goamzEC2
)
DetachVolume
(
volumeI
d
string
)
(
resp
*
ec2
.
SimpleResp
,
err
error
)
{
func
(
s
*
goamzEC2
)
DetachVolume
(
volumeI
D
string
)
(
resp
*
ec2
.
SimpleResp
,
err
error
)
{
return
s
.
ec2
.
DetachVolume
(
volumeI
d
)
return
s
.
ec2
.
DetachVolume
(
volumeI
D
)
}
}
func
(
s
*
goamzEC2
)
Volumes
(
volumeI
d
s
[]
string
,
filter
*
ec2
.
Filter
)
(
resp
*
ec2
.
VolumesResp
,
err
error
)
{
func
(
s
*
goamzEC2
)
Volumes
(
volumeI
D
s
[]
string
,
filter
*
ec2
.
Filter
)
(
resp
*
ec2
.
VolumesResp
,
err
error
)
{
return
s
.
ec2
.
Volumes
(
volumeI
d
s
,
filter
)
return
s
.
ec2
.
Volumes
(
volumeI
D
s
,
filter
)
}
}
func
(
s
*
goamzEC2
)
CreateVolume
(
request
*
ec2
.
CreateVolume
)
(
resp
*
ec2
.
CreateVolumeResp
,
err
error
)
{
func
(
s
*
goamzEC2
)
CreateVolume
(
request
*
ec2
.
CreateVolume
)
(
resp
*
ec2
.
CreateVolumeResp
,
err
error
)
{
return
s
.
ec2
.
CreateVolume
(
request
)
return
s
.
ec2
.
CreateVolume
(
request
)
}
}
func
(
s
*
goamzEC2
)
DeleteVolume
(
volumeI
d
string
)
(
resp
*
ec2
.
SimpleResp
,
err
error
)
{
func
(
s
*
goamzEC2
)
DeleteVolume
(
volumeI
D
string
)
(
resp
*
ec2
.
SimpleResp
,
err
error
)
{
return
s
.
ec2
.
DeleteVolume
(
volumeI
d
)
return
s
.
ec2
.
DeleteVolume
(
volumeI
D
)
}
}
func
init
()
{
func
init
()
{
...
@@ -641,7 +641,7 @@ func (self *awsInstance) getInfo() (*ec2.Instance, error) {
...
@@ -641,7 +641,7 @@ func (self *awsInstance) getInfo() (*ec2.Instance, error) {
// Assigns an unused mount device for the specified volume.
// Assigns an unused mount device for the specified volume.
// If the volume is already assigned, this will return the existing mount device and true
// If the volume is already assigned, this will return the existing mount device and true
func
(
self
*
awsInstance
)
assignMountDevice
(
volumeI
d
string
)
(
mountDevice
string
,
alreadyAttached
bool
,
err
error
)
{
func
(
self
*
awsInstance
)
assignMountDevice
(
volumeI
D
string
)
(
mountDevice
string
,
alreadyAttached
bool
,
err
error
)
{
instanceType
:=
self
.
getInstanceType
()
instanceType
:=
self
.
getInstanceType
()
if
instanceType
==
nil
{
if
instanceType
==
nil
{
return
""
,
false
,
fmt
.
Errorf
(
"could not get instance type for instance: %s"
,
self
.
awsID
)
return
""
,
false
,
fmt
.
Errorf
(
"could not get instance type for instance: %s"
,
self
.
awsID
)
...
@@ -661,15 +661,15 @@ func (self *awsInstance) assignMountDevice(volumeId string) (mountDevice string,
...
@@ -661,15 +661,15 @@ func (self *awsInstance) assignMountDevice(volumeId string) (mountDevice string,
}
}
deviceMappings
:=
map
[
string
]
string
{}
deviceMappings
:=
map
[
string
]
string
{}
for
_
,
blockDevice
:=
range
info
.
BlockDevices
{
for
_
,
blockDevice
:=
range
info
.
BlockDevices
{
deviceMappings
[
blockDevice
.
DeviceName
]
=
blockDevice
.
VolumeI
d
deviceMappings
[
blockDevice
.
DeviceName
]
=
blockDevice
.
VolumeI
D
}
}
self
.
deviceMappings
=
deviceMappings
self
.
deviceMappings
=
deviceMappings
}
}
// Check to see if this volume is already assigned a device on this machine
// Check to see if this volume is already assigned a device on this machine
for
deviceName
,
mappingVolumeI
d
:=
range
self
.
deviceMappings
{
for
deviceName
,
mappingVolumeI
D
:=
range
self
.
deviceMappings
{
if
volumeI
d
==
mappingVolumeId
{
if
volumeI
D
==
mappingVolumeID
{
glog
.
Warningf
(
"Got assignment call for already-assigned volume: %s@%s"
,
deviceName
,
mappingVolumeI
d
)
glog
.
Warningf
(
"Got assignment call for already-assigned volume: %s@%s"
,
deviceName
,
mappingVolumeI
D
)
return
deviceName
,
true
,
nil
return
deviceName
,
true
,
nil
}
}
}
}
...
@@ -690,26 +690,26 @@ func (self *awsInstance) assignMountDevice(volumeId string) (mountDevice string,
...
@@ -690,26 +690,26 @@ func (self *awsInstance) assignMountDevice(volumeId string) (mountDevice string,
return
""
,
false
,
nil
return
""
,
false
,
nil
}
}
self
.
deviceMappings
[
chosen
]
=
volumeI
d
self
.
deviceMappings
[
chosen
]
=
volumeI
D
glog
.
V
(
2
)
.
Infof
(
"Assigned mount device %s -> volume %s"
,
chosen
,
volumeI
d
)
glog
.
V
(
2
)
.
Infof
(
"Assigned mount device %s -> volume %s"
,
chosen
,
volumeI
D
)
return
chosen
,
false
,
nil
return
chosen
,
false
,
nil
}
}
func
(
self
*
awsInstance
)
releaseMountDevice
(
volumeI
d
string
,
mountDevice
string
)
{
func
(
self
*
awsInstance
)
releaseMountDevice
(
volumeI
D
string
,
mountDevice
string
)
{
self
.
mutex
.
Lock
()
self
.
mutex
.
Lock
()
defer
self
.
mutex
.
Unlock
()
defer
self
.
mutex
.
Unlock
()
existingVolumeI
d
,
found
:=
self
.
deviceMappings
[
mountDevice
]
existingVolumeI
D
,
found
:=
self
.
deviceMappings
[
mountDevice
]
if
!
found
{
if
!
found
{
glog
.
Errorf
(
"releaseMountDevice on non-allocated device"
)
glog
.
Errorf
(
"releaseMountDevice on non-allocated device"
)
return
return
}
}
if
volumeI
d
!=
existingVolumeId
{
if
volumeI
D
!=
existingVolumeID
{
glog
.
Errorf
(
"releaseMountDevice on device assigned to different volume"
)
glog
.
Errorf
(
"releaseMountDevice on device assigned to different volume"
)
return
return
}
}
glog
.
V
(
2
)
.
Infof
(
"Releasing mount device mapping: %s -> volume %s"
,
mountDevice
,
volumeI
d
)
glog
.
V
(
2
)
.
Infof
(
"Releasing mount device mapping: %s -> volume %s"
,
mountDevice
,
volumeI
D
)
delete
(
self
.
deviceMappings
,
mountDevice
)
delete
(
self
.
deviceMappings
,
mountDevice
)
}
}
...
@@ -938,7 +938,7 @@ func (aws *AWSCloud) CreateVolume(volumeOptions *VolumeOptions) (string, error)
...
@@ -938,7 +938,7 @@ func (aws *AWSCloud) CreateVolume(volumeOptions *VolumeOptions) (string, error)
}
}
az
:=
response
.
AvailZone
az
:=
response
.
AvailZone
awsID
:=
response
.
VolumeI
d
awsID
:=
response
.
VolumeI
D
volumeName
:=
"aws://"
+
az
+
"/"
+
awsID
volumeName
:=
"aws://"
+
az
+
"/"
+
awsID
...
...
pkg/cloudprovider/aws/aws_test.go
View file @
933cf60a
...
@@ -191,15 +191,15 @@ func (self *FakeMetadata) GetMetaData(key string) ([]byte, error) {
...
@@ -191,15 +191,15 @@ func (self *FakeMetadata) GetMetaData(key string) ([]byte, error) {
}
}
}
}
func
(
ec2
*
FakeEC2
)
AttachVolume
(
volumeI
d
string
,
instanceId
string
,
mountDevice
string
)
(
resp
*
ec2
.
AttachVolumeResp
,
err
error
)
{
func
(
ec2
*
FakeEC2
)
AttachVolume
(
volumeI
D
string
,
instanceId
string
,
mountDevice
string
)
(
resp
*
ec2
.
AttachVolumeResp
,
err
error
)
{
panic
(
"Not implemented"
)
panic
(
"Not implemented"
)
}
}
func
(
ec2
*
FakeEC2
)
DetachVolume
(
volumeI
d
string
)
(
resp
*
ec2
.
SimpleResp
,
err
error
)
{
func
(
ec2
*
FakeEC2
)
DetachVolume
(
volumeI
D
string
)
(
resp
*
ec2
.
SimpleResp
,
err
error
)
{
panic
(
"Not implemented"
)
panic
(
"Not implemented"
)
}
}
func
(
ec2
*
FakeEC2
)
Volumes
(
volumeI
d
s
[]
string
,
filter
*
ec2
.
Filter
)
(
resp
*
ec2
.
VolumesResp
,
err
error
)
{
func
(
ec2
*
FakeEC2
)
Volumes
(
volumeI
D
s
[]
string
,
filter
*
ec2
.
Filter
)
(
resp
*
ec2
.
VolumesResp
,
err
error
)
{
panic
(
"Not implemented"
)
panic
(
"Not implemented"
)
}
}
...
@@ -207,7 +207,7 @@ func (ec2 *FakeEC2) CreateVolume(request *ec2.CreateVolume) (resp *ec2.CreateVol
...
@@ -207,7 +207,7 @@ func (ec2 *FakeEC2) CreateVolume(request *ec2.CreateVolume) (resp *ec2.CreateVol
panic
(
"Not implemented"
)
panic
(
"Not implemented"
)
}
}
func
(
ec2
*
FakeEC2
)
DeleteVolume
(
volumeI
d
string
)
(
resp
*
ec2
.
SimpleResp
,
err
error
)
{
func
(
ec2
*
FakeEC2
)
DeleteVolume
(
volumeI
D
string
)
(
resp
*
ec2
.
SimpleResp
,
err
error
)
{
panic
(
"Not implemented"
)
panic
(
"Not implemented"
)
}
}
...
...
pkg/scheduler/predicates.go
View file @
933cf60a
...
@@ -62,12 +62,12 @@ func isVolumeConflict(volume api.Volume, pod *api.Pod) bool {
...
@@ -62,12 +62,12 @@ func isVolumeConflict(volume api.Volume, pod *api.Pod) bool {
}
}
}
}
if
volume
.
AWSElasticBlockStore
!=
nil
{
if
volume
.
AWSElasticBlockStore
!=
nil
{
volumeI
d
:=
volume
.
AWSElasticBlockStore
.
VolumeId
volumeI
D
:=
volume
.
AWSElasticBlockStore
.
VolumeID
manifest
:=
&
(
pod
.
Spec
)
manifest
:=
&
(
pod
.
Spec
)
for
ix
:=
range
manifest
.
Volumes
{
for
ix
:=
range
manifest
.
Volumes
{
if
manifest
.
Volumes
[
ix
]
.
AWSElasticBlockStore
!=
nil
&&
if
manifest
.
Volumes
[
ix
]
.
AWSElasticBlockStore
!=
nil
&&
manifest
.
Volumes
[
ix
]
.
AWSElasticBlockStore
.
VolumeI
d
==
volumeId
{
manifest
.
Volumes
[
ix
]
.
AWSElasticBlockStore
.
VolumeI
D
==
volumeID
{
return
true
return
true
}
}
}
}
...
...
pkg/scheduler/predicates_test.go
View file @
933cf60a
...
@@ -327,7 +327,7 @@ func TestAWSDiskConflicts(t *testing.T) {
...
@@ -327,7 +327,7 @@ func TestAWSDiskConflicts(t *testing.T) {
{
{
VolumeSource
:
api
.
VolumeSource
{
VolumeSource
:
api
.
VolumeSource
{
AWSElasticBlockStore
:
&
api
.
AWSElasticBlockStoreVolumeSource
{
AWSElasticBlockStore
:
&
api
.
AWSElasticBlockStoreVolumeSource
{
VolumeI
d
:
"foo"
,
VolumeI
D
:
"foo"
,
},
},
},
},
},
},
...
@@ -338,7 +338,7 @@ func TestAWSDiskConflicts(t *testing.T) {
...
@@ -338,7 +338,7 @@ func TestAWSDiskConflicts(t *testing.T) {
{
{
VolumeSource
:
api
.
VolumeSource
{
VolumeSource
:
api
.
VolumeSource
{
AWSElasticBlockStore
:
&
api
.
AWSElasticBlockStoreVolumeSource
{
AWSElasticBlockStore
:
&
api
.
AWSElasticBlockStoreVolumeSource
{
VolumeI
d
:
"bar"
,
VolumeI
D
:
"bar"
,
},
},
},
},
},
},
...
...
pkg/volume/aws_pd/aws_pd.go
View file @
933cf60a
...
@@ -77,7 +77,7 @@ func (plugin *awsElasticBlockStorePlugin) NewBuilder(spec *api.Volume, podRef *a
...
@@ -77,7 +77,7 @@ func (plugin *awsElasticBlockStorePlugin) NewBuilder(spec *api.Volume, podRef *a
}
}
func
(
plugin
*
awsElasticBlockStorePlugin
)
newBuilderInternal
(
spec
*
api
.
Volume
,
podUID
types
.
UID
,
manager
pdManager
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
func
(
plugin
*
awsElasticBlockStorePlugin
)
newBuilderInternal
(
spec
*
api
.
Volume
,
podUID
types
.
UID
,
manager
pdManager
,
mounter
mount
.
Interface
)
(
volume
.
Builder
,
error
)
{
volumeI
d
:=
spec
.
AWSElasticBlockStore
.
VolumeId
volumeI
D
:=
spec
.
AWSElasticBlockStore
.
VolumeID
fsType
:=
spec
.
AWSElasticBlockStore
.
FSType
fsType
:=
spec
.
AWSElasticBlockStore
.
FSType
partition
:=
""
partition
:=
""
if
spec
.
AWSElasticBlockStore
.
Partition
!=
0
{
if
spec
.
AWSElasticBlockStore
.
Partition
!=
0
{
...
@@ -88,7 +88,7 @@ func (plugin *awsElasticBlockStorePlugin) newBuilderInternal(spec *api.Volume, p
...
@@ -88,7 +88,7 @@ func (plugin *awsElasticBlockStorePlugin) newBuilderInternal(spec *api.Volume, p
return
&
awsElasticBlockStore
{
return
&
awsElasticBlockStore
{
podUID
:
podUID
,
podUID
:
podUID
,
volName
:
spec
.
Name
,
volName
:
spec
.
Name
,
volumeI
d
:
volumeId
,
volumeI
D
:
volumeID
,
fsType
:
fsType
,
fsType
:
fsType
,
partition
:
partition
,
partition
:
partition
,
readOnly
:
readOnly
,
readOnly
:
readOnly
,
...
@@ -129,7 +129,7 @@ type awsElasticBlockStore struct {
...
@@ -129,7 +129,7 @@ type awsElasticBlockStore struct {
volName
string
volName
string
podUID
types
.
UID
podUID
types
.
UID
// Unique id of the PD, used to find the disk resource in the provider.
// Unique id of the PD, used to find the disk resource in the provider.
volumeI
d
string
volumeI
D
string
// Filesystem type, optional.
// Filesystem type, optional.
fsType
string
fsType
string
// Specifies the partition to mount
// Specifies the partition to mount
...
@@ -183,7 +183,7 @@ func (pd *awsElasticBlockStore) SetUpAt(dir string) error {
...
@@ -183,7 +183,7 @@ func (pd *awsElasticBlockStore) SetUpAt(dir string) error {
return
nil
return
nil
}
}
globalPDPath
:=
makeGlobalPDPath
(
pd
.
plugin
.
host
,
pd
.
volumeI
d
)
globalPDPath
:=
makeGlobalPDPath
(
pd
.
plugin
.
host
,
pd
.
volumeI
D
)
if
err
:=
pd
.
manager
.
AttachAndMountDisk
(
pd
,
globalPDPath
);
err
!=
nil
{
if
err
:=
pd
.
manager
.
AttachAndMountDisk
(
pd
,
globalPDPath
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -232,14 +232,14 @@ func (pd *awsElasticBlockStore) SetUpAt(dir string) error {
...
@@ -232,14 +232,14 @@ func (pd *awsElasticBlockStore) SetUpAt(dir string) error {
return
nil
return
nil
}
}
func
makeGlobalPDPath
(
host
volume
.
VolumeHost
,
volumeI
d
string
)
string
{
func
makeGlobalPDPath
(
host
volume
.
VolumeHost
,
volumeI
D
string
)
string
{
// Clean up the URI to be more fs-friendly
// Clean up the URI to be more fs-friendly
name
:=
volumeI
d
name
:=
volumeI
D
name
=
strings
.
Replace
(
name
,
"://"
,
"/"
,
-
1
)
name
=
strings
.
Replace
(
name
,
"://"
,
"/"
,
-
1
)
return
path
.
Join
(
host
.
GetPluginDir
(
awsElasticBlockStorePluginName
),
"mounts"
,
name
)
return
path
.
Join
(
host
.
GetPluginDir
(
awsElasticBlockStorePluginName
),
"mounts"
,
name
)
}
}
func
getVolumeI
d
FromGlobalMount
(
host
volume
.
VolumeHost
,
globalPath
string
)
(
string
,
error
)
{
func
getVolumeI
D
FromGlobalMount
(
host
volume
.
VolumeHost
,
globalPath
string
)
(
string
,
error
)
{
basePath
:=
path
.
Join
(
host
.
GetPluginDir
(
awsElasticBlockStorePluginName
),
"mounts"
)
basePath
:=
path
.
Join
(
host
.
GetPluginDir
(
awsElasticBlockStorePluginName
),
"mounts"
)
rel
,
err
:=
filepath
.
Rel
(
basePath
,
globalPath
)
rel
,
err
:=
filepath
.
Rel
(
basePath
,
globalPath
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -249,12 +249,12 @@ func getVolumeIdFromGlobalMount(host volume.VolumeHost, globalPath string) (stri
...
@@ -249,12 +249,12 @@ func getVolumeIdFromGlobalMount(host volume.VolumeHost, globalPath string) (stri
return
""
,
fmt
.
Errorf
(
"Unexpected mount path: "
+
globalPath
)
return
""
,
fmt
.
Errorf
(
"Unexpected mount path: "
+
globalPath
)
}
}
// Reverse the :// replacement done in makeGlobalPDPath
// Reverse the :// replacement done in makeGlobalPDPath
volumeI
d
:=
rel
volumeI
D
:=
rel
if
strings
.
HasPrefix
(
volumeI
d
,
"aws/"
)
{
if
strings
.
HasPrefix
(
volumeI
D
,
"aws/"
)
{
volumeI
d
=
strings
.
Replace
(
volumeId
,
"aws/"
,
"aws://"
,
1
)
volumeI
D
=
strings
.
Replace
(
volumeID
,
"aws/"
,
"aws://"
,
1
)
}
}
glog
.
V
(
2
)
.
Info
(
"Mapping mount dir "
,
globalPath
,
" to volumeI
d "
,
volumeId
)
glog
.
V
(
2
)
.
Info
(
"Mapping mount dir "
,
globalPath
,
" to volumeI
D "
,
volumeID
)
return
volumeI
d
,
nil
return
volumeI
D
,
nil
}
}
func
(
pd
*
awsElasticBlockStore
)
GetPath
()
string
{
func
(
pd
*
awsElasticBlockStore
)
GetPath
()
string
{
...
@@ -294,14 +294,14 @@ func (pd *awsElasticBlockStore) TearDownAt(dir string) error {
...
@@ -294,14 +294,14 @@ func (pd *awsElasticBlockStore) TearDownAt(dir string) error {
// If len(refs) is 1, then all bind mounts have been removed, and the
// If len(refs) is 1, then all bind mounts have been removed, and the
// remaining reference is the global mount. It is safe to detach.
// remaining reference is the global mount. It is safe to detach.
if
len
(
refs
)
==
1
{
if
len
(
refs
)
==
1
{
// pd.volumeI
d
is not initially set for volume-cleaners, so set it here.
// pd.volumeI
D
is not initially set for volume-cleaners, so set it here.
pd
.
volumeI
d
,
err
=
getVolumeId
FromGlobalMount
(
pd
.
plugin
.
host
,
refs
[
0
])
pd
.
volumeI
D
,
err
=
getVolumeID
FromGlobalMount
(
pd
.
plugin
.
host
,
refs
[
0
])
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
2
)
.
Info
(
"Could not determine volumeI
d
from mountpoint "
,
refs
[
0
],
": "
,
err
)
glog
.
V
(
2
)
.
Info
(
"Could not determine volumeI
D
from mountpoint "
,
refs
[
0
],
": "
,
err
)
return
err
return
err
}
}
if
err
:=
pd
.
manager
.
DetachDisk
(
pd
);
err
!=
nil
{
if
err
:=
pd
.
manager
.
DetachDisk
(
pd
);
err
!=
nil
{
glog
.
V
(
2
)
.
Info
(
"Error detaching disk "
,
pd
.
volumeI
d
,
": "
,
err
)
glog
.
V
(
2
)
.
Info
(
"Error detaching disk "
,
pd
.
volumeI
D
,
": "
,
err
)
return
err
return
err
}
}
}
}
...
...
pkg/volume/aws_pd/aws_pd_test.go
View file @
933cf60a
...
@@ -72,7 +72,7 @@ type fakePDManager struct{}
...
@@ -72,7 +72,7 @@ type fakePDManager struct{}
// TODO(jonesdl) To fully test this, we could create a loopback device
// TODO(jonesdl) To fully test this, we could create a loopback device
// and mount that instead.
// and mount that instead.
func
(
fake
*
fakePDManager
)
AttachAndMountDisk
(
pd
*
awsElasticBlockStore
,
globalPDPath
string
)
error
{
func
(
fake
*
fakePDManager
)
AttachAndMountDisk
(
pd
*
awsElasticBlockStore
,
globalPDPath
string
)
error
{
globalPath
:=
makeGlobalPDPath
(
pd
.
plugin
.
host
,
pd
.
volumeI
d
)
globalPath
:=
makeGlobalPDPath
(
pd
.
plugin
.
host
,
pd
.
volumeI
D
)
err
:=
os
.
MkdirAll
(
globalPath
,
0750
)
err
:=
os
.
MkdirAll
(
globalPath
,
0750
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -81,7 +81,7 @@ func (fake *fakePDManager) AttachAndMountDisk(pd *awsElasticBlockStore, globalPD
...
@@ -81,7 +81,7 @@ func (fake *fakePDManager) AttachAndMountDisk(pd *awsElasticBlockStore, globalPD
}
}
func
(
fake
*
fakePDManager
)
DetachDisk
(
pd
*
awsElasticBlockStore
)
error
{
func
(
fake
*
fakePDManager
)
DetachDisk
(
pd
*
awsElasticBlockStore
)
error
{
globalPath
:=
makeGlobalPDPath
(
pd
.
plugin
.
host
,
pd
.
volumeI
d
)
globalPath
:=
makeGlobalPDPath
(
pd
.
plugin
.
host
,
pd
.
volumeI
D
)
err
:=
os
.
RemoveAll
(
globalPath
)
err
:=
os
.
RemoveAll
(
globalPath
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -101,7 +101,7 @@ func TestPlugin(t *testing.T) {
...
@@ -101,7 +101,7 @@ func TestPlugin(t *testing.T) {
Name
:
"vol1"
,
Name
:
"vol1"
,
VolumeSource
:
api
.
VolumeSource
{
VolumeSource
:
api
.
VolumeSource
{
AWSElasticBlockStore
:
&
api
.
AWSElasticBlockStoreVolumeSource
{
AWSElasticBlockStore
:
&
api
.
AWSElasticBlockStoreVolumeSource
{
VolumeI
d
:
"pd"
,
VolumeI
D
:
"pd"
,
FSType
:
"ext4"
,
FSType
:
"ext4"
,
},
},
},
},
...
...
pkg/volume/aws_pd/aws_util.go
View file @
933cf60a
...
@@ -40,7 +40,7 @@ func (util *AWSDiskUtil) AttachAndMountDisk(pd *awsElasticBlockStore, globalPDPa
...
@@ -40,7 +40,7 @@ func (util *AWSDiskUtil) AttachAndMountDisk(pd *awsElasticBlockStore, globalPDPa
if
pd
.
readOnly
{
if
pd
.
readOnly
{
flags
=
mount
.
FlagReadOnly
flags
=
mount
.
FlagReadOnly
}
}
devicePath
,
err
:=
volumes
.
AttachDisk
(
""
,
pd
.
volumeI
d
,
pd
.
readOnly
)
devicePath
,
err
:=
volumes
.
AttachDisk
(
""
,
pd
.
volumeI
D
,
pd
.
readOnly
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -89,7 +89,7 @@ func (util *AWSDiskUtil) AttachAndMountDisk(pd *awsElasticBlockStore, globalPDPa
...
@@ -89,7 +89,7 @@ func (util *AWSDiskUtil) AttachAndMountDisk(pd *awsElasticBlockStore, globalPDPa
// Unmounts the device and detaches the disk from the kubelet's host machine.
// Unmounts the device and detaches the disk from the kubelet's host machine.
func
(
util
*
AWSDiskUtil
)
DetachDisk
(
pd
*
awsElasticBlockStore
)
error
{
func
(
util
*
AWSDiskUtil
)
DetachDisk
(
pd
*
awsElasticBlockStore
)
error
{
// Unmount the global PD mount, which should be the only one.
// Unmount the global PD mount, which should be the only one.
globalPDPath
:=
makeGlobalPDPath
(
pd
.
plugin
.
host
,
pd
.
volumeI
d
)
globalPDPath
:=
makeGlobalPDPath
(
pd
.
plugin
.
host
,
pd
.
volumeI
D
)
if
err
:=
pd
.
mounter
.
Unmount
(
globalPDPath
,
0
);
err
!=
nil
{
if
err
:=
pd
.
mounter
.
Unmount
(
globalPDPath
,
0
);
err
!=
nil
{
glog
.
V
(
2
)
.
Info
(
"Error unmount dir "
,
globalPDPath
,
": "
,
err
)
glog
.
V
(
2
)
.
Info
(
"Error unmount dir "
,
globalPDPath
,
": "
,
err
)
return
err
return
err
...
@@ -101,11 +101,11 @@ func (util *AWSDiskUtil) DetachDisk(pd *awsElasticBlockStore) error {
...
@@ -101,11 +101,11 @@ func (util *AWSDiskUtil) DetachDisk(pd *awsElasticBlockStore) error {
// Detach the disk
// Detach the disk
volumes
,
err
:=
pd
.
getVolumeProvider
()
volumes
,
err
:=
pd
.
getVolumeProvider
()
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
2
)
.
Info
(
"Error getting volume provider for volumeI
d "
,
pd
.
volumeId
,
": "
,
err
)
glog
.
V
(
2
)
.
Info
(
"Error getting volume provider for volumeI
D "
,
pd
.
volumeID
,
": "
,
err
)
return
err
return
err
}
}
if
err
:=
volumes
.
DetachDisk
(
""
,
pd
.
volumeI
d
);
err
!=
nil
{
if
err
:=
volumes
.
DetachDisk
(
""
,
pd
.
volumeI
D
);
err
!=
nil
{
glog
.
V
(
2
)
.
Info
(
"Error detaching disk "
,
pd
.
volumeI
d
,
": "
,
err
)
glog
.
V
(
2
)
.
Info
(
"Error detaching disk "
,
pd
.
volumeI
D
,
": "
,
err
)
return
err
return
err
}
}
return
nil
return
nil
...
...
test/e2e/pd.go
View file @
933cf60a
...
@@ -275,7 +275,7 @@ func testPDPod(diskName, targetHost string, readOnly bool) *api.Pod {
...
@@ -275,7 +275,7 @@ func testPDPod(diskName, targetHost string, readOnly bool) *api.Pod {
Name
:
"testpd"
,
Name
:
"testpd"
,
VolumeSource
:
api
.
VolumeSource
{
VolumeSource
:
api
.
VolumeSource
{
AWSElasticBlockStore
:
&
api
.
AWSElasticBlockStoreVolumeSource
{
AWSElasticBlockStore
:
&
api
.
AWSElasticBlockStoreVolumeSource
{
VolumeI
d
:
diskName
,
VolumeI
D
:
diskName
,
FSType
:
"ext4"
,
FSType
:
"ext4"
,
ReadOnly
:
readOnly
,
ReadOnly
:
readOnly
,
},
},
...
...
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