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
2afc1840
Commit
2afc1840
authored
Apr 09, 2015
by
Justin Santa Barbara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Style: awsId -> awsID
parent
46f9c2cc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
25 deletions
+25
-25
aws.go
pkg/cloudprovider/aws/aws.go
+25
-25
No files found.
pkg/cloudprovider/aws/aws.go
View file @
2afc1840
...
...
@@ -593,7 +593,7 @@ type awsInstance struct {
ec2
EC2
// id in AWS
awsI
d
string
awsI
D
string
mutex
sync
.
Mutex
...
...
@@ -602,8 +602,8 @@ type awsInstance struct {
deviceMappings
map
[
string
]
string
}
func
newAwsInstance
(
ec2
EC2
,
awsI
d
string
)
*
awsInstance
{
self
:=
&
awsInstance
{
ec2
:
ec2
,
awsI
d
:
awsId
}
func
newAwsInstance
(
ec2
EC2
,
awsI
D
string
)
*
awsInstance
{
self
:=
&
awsInstance
{
ec2
:
ec2
,
awsI
D
:
awsID
}
// We lazy-init deviceMappings
self
.
deviceMappings
=
nil
...
...
@@ -620,21 +620,21 @@ func (self *awsInstance) getInstanceType() *awsInstanceType {
// Gets the full information about this instance from the EC2 API
func
(
self
*
awsInstance
)
getInfo
()
(
*
ec2
.
Instance
,
error
)
{
resp
,
err
:=
self
.
ec2
.
Instances
([]
string
{
self
.
awsI
d
},
nil
)
resp
,
err
:=
self
.
ec2
.
Instances
([]
string
{
self
.
awsI
D
},
nil
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error querying ec2 for instance info: %v"
,
err
)
}
if
len
(
resp
.
Reservations
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"no reservations found for instance: %s"
,
self
.
awsI
d
)
return
nil
,
fmt
.
Errorf
(
"no reservations found for instance: %s"
,
self
.
awsI
D
)
}
if
len
(
resp
.
Reservations
)
>
1
{
return
nil
,
fmt
.
Errorf
(
"multiple reservations found for instance: %s"
,
self
.
awsI
d
)
return
nil
,
fmt
.
Errorf
(
"multiple reservations found for instance: %s"
,
self
.
awsI
D
)
}
if
len
(
resp
.
Reservations
[
0
]
.
Instances
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"no instances found for instance: %s"
,
self
.
awsI
d
)
return
nil
,
fmt
.
Errorf
(
"no instances found for instance: %s"
,
self
.
awsI
D
)
}
if
len
(
resp
.
Reservations
[
0
]
.
Instances
)
>
1
{
return
nil
,
fmt
.
Errorf
(
"multiple instances found for instance: %s"
,
self
.
awsI
d
)
return
nil
,
fmt
.
Errorf
(
"multiple instances found for instance: %s"
,
self
.
awsI
D
)
}
return
&
resp
.
Reservations
[
0
]
.
Instances
[
0
],
nil
}
...
...
@@ -644,7 +644,7 @@ func (self *awsInstance) getInfo() (*ec2.Instance, error) {
func
(
self
*
awsInstance
)
assignMountDevice
(
volumeId
string
)
(
mountDevice
string
,
alreadyAttached
bool
,
err
error
)
{
instanceType
:=
self
.
getInstanceType
()
if
instanceType
==
nil
{
return
""
,
false
,
fmt
.
Errorf
(
"could not get instance type for instance: %s"
,
self
.
awsI
d
)
return
""
,
false
,
fmt
.
Errorf
(
"could not get instance type for instance: %s"
,
self
.
awsI
D
)
}
// We lock to prevent concurrent mounts from conflicting
...
...
@@ -719,7 +719,7 @@ type awsDisk struct {
// Name in k8s
name
string
// id in AWS
awsI
d
string
awsI
D
string
// az which holds the volume
az
string
}
...
...
@@ -735,13 +735,13 @@ func newAwsDisk(ec2 EC2, name string) (*awsDisk, error) {
return
nil
,
fmt
.
Errorf
(
"Invalid scheme for AWS volume (%s)"
,
name
)
}
awsI
d
:=
url
.
Path
if
len
(
awsI
d
)
>
1
&&
awsId
[
0
]
==
'/'
{
awsI
d
=
awsId
[
1
:
]
awsI
D
:=
url
.
Path
if
len
(
awsI
D
)
>
1
&&
awsID
[
0
]
==
'/'
{
awsI
D
=
awsID
[
1
:
]
}
// TODO: Regex match?
if
strings
.
Contains
(
awsI
d
,
"/"
)
||
!
strings
.
HasPrefix
(
awsId
,
"vol-"
)
{
if
strings
.
Contains
(
awsI
D
,
"/"
)
||
!
strings
.
HasPrefix
(
awsID
,
"vol-"
)
{
return
nil
,
fmt
.
Errorf
(
"Invalid format for AWS volume (%s)"
,
name
)
}
az
:=
url
.
Host
...
...
@@ -751,21 +751,21 @@ func newAwsDisk(ec2 EC2, name string) (*awsDisk, error) {
if
az
==
""
{
return
nil
,
fmt
.
Errorf
(
"Invalid format for AWS volume (%s)"
,
name
)
}
disk
:=
&
awsDisk
{
ec2
:
ec2
,
name
:
name
,
awsI
d
:
awsId
,
az
:
az
}
disk
:=
&
awsDisk
{
ec2
:
ec2
,
name
:
name
,
awsI
D
:
awsID
,
az
:
az
}
return
disk
,
nil
}
// Gets the full information about this volume from the EC2 API
func
(
self
*
awsDisk
)
getInfo
()
(
*
ec2
.
Volume
,
error
)
{
resp
,
err
:=
self
.
ec2
.
Volumes
([]
string
{
self
.
awsI
d
},
nil
)
resp
,
err
:=
self
.
ec2
.
Volumes
([]
string
{
self
.
awsI
D
},
nil
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error querying ec2 for volume info: %v"
,
err
)
}
if
len
(
resp
.
Volumes
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"no volumes found for volume: %s"
,
self
.
awsI
d
)
return
nil
,
fmt
.
Errorf
(
"no volumes found for volume: %s"
,
self
.
awsI
D
)
}
if
len
(
resp
.
Volumes
)
>
1
{
return
nil
,
fmt
.
Errorf
(
"multiple volumes found for volume: %s"
,
self
.
awsI
d
)
return
nil
,
fmt
.
Errorf
(
"multiple volumes found for volume: %s"
,
self
.
awsI
D
)
}
return
&
resp
.
Volumes
[
0
],
nil
}
...
...
@@ -811,7 +811,7 @@ func (self *awsDisk) waitForAttachmentStatus(status string) error {
// Deletes the EBS disk
func
(
self
*
awsDisk
)
delete
()
error
{
_
,
err
:=
self
.
ec2
.
DeleteVolume
(
self
.
awsI
d
)
_
,
err
:=
self
.
ec2
.
DeleteVolume
(
self
.
awsI
D
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error delete EBS volumes: %v"
,
err
)
}
...
...
@@ -867,7 +867,7 @@ func (aws *AWSCloud) AttachDisk(instanceName string, diskName string, readOnly b
return
""
,
errors
.
New
(
"AWS volumes cannot be mounted read-only"
)
}
mountDevice
,
alreadyAttached
,
err
:=
awsInstance
.
assignMountDevice
(
disk
.
awsI
d
)
mountDevice
,
alreadyAttached
,
err
:=
awsInstance
.
assignMountDevice
(
disk
.
awsI
D
)
if
err
!=
nil
{
return
""
,
err
}
...
...
@@ -875,12 +875,12 @@ func (aws *AWSCloud) AttachDisk(instanceName string, diskName string, readOnly b
attached
:=
false
defer
func
()
{
if
!
attached
{
awsInstance
.
releaseMountDevice
(
disk
.
awsI
d
,
mountDevice
)
awsInstance
.
releaseMountDevice
(
disk
.
awsI
D
,
mountDevice
)
}
}()
if
!
alreadyAttached
{
attachResponse
,
err
:=
aws
.
ec2
.
AttachVolume
(
disk
.
awsI
d
,
awsInstance
.
awsId
,
mountDevice
)
attachResponse
,
err
:=
aws
.
ec2
.
AttachVolume
(
disk
.
awsI
D
,
awsInstance
.
awsID
,
mountDevice
)
if
err
!=
nil
{
// TODO: Check if the volume was concurrently attached?
return
""
,
fmt
.
Errorf
(
"Error attaching EBS volume: %v"
,
err
)
...
...
@@ -912,7 +912,7 @@ func (aws *AWSCloud) DetachDisk(instanceName string, diskName string) error {
}
// TODO: We should specify the InstanceID and the Device, for safety
response
,
err
:=
aws
.
ec2
.
DetachVolume
(
disk
.
awsI
d
)
response
,
err
:=
aws
.
ec2
.
DetachVolume
(
disk
.
awsI
D
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error detaching EBS volume: %v"
,
err
)
}
...
...
@@ -938,9 +938,9 @@ func (aws *AWSCloud) CreateVolume(volumeOptions *VolumeOptions) (string, error)
}
az
:=
response
.
AvailZone
awsI
d
:=
response
.
VolumeId
awsI
D
:=
response
.
VolumeId
volumeName
:=
"aws://"
+
az
+
"/"
+
awsI
d
volumeName
:=
"aws://"
+
az
+
"/"
+
awsI
D
return
volumeName
,
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