Skip to content

Commit

Permalink
Merge pull request #10181 from swagiaal/aws-ebs-name
Browse files Browse the repository at this point in the history
Use instance availability zone for AWS EBS
  • Loading branch information
yujuhong committed Jul 6, 2015
2 parents 04018f9 + 4a6a492 commit 736b3cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/aws_ebs/aws-ebs-web.yaml
Expand Up @@ -16,6 +16,6 @@ spec:
volumes:
- name: html-volume
awsElasticBlockStore:
# Enter the volume region and ID below
volumeID: aws://{region}/{volume ID}
# Enter the volume ID below
volumeID: volume_ID
fsType: ext4
13 changes: 8 additions & 5 deletions pkg/cloudprovider/aws/aws.go
Expand Up @@ -1106,7 +1106,10 @@ type awsDisk struct {
az string
}

func newAWSDisk(ec2 EC2, name string) (*awsDisk, error) {
func newAWSDisk(aws *AWSCloud, name string) (*awsDisk, error) {
if !strings.HasPrefix(name, "aws://") {
name = "aws://" + aws.availabilityZone + "/" + name
}
// name looks like aws://availability-zone/id
url, err := url.Parse(name)
if err != nil {
Expand All @@ -1133,7 +1136,7 @@ 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, awsID: awsID, az: az}
disk := &awsDisk{ec2: aws.ec2, name: name, awsID: awsID, az: az}
return disk, nil
}

Expand Down Expand Up @@ -1261,7 +1264,7 @@ func (aws *AWSCloud) getAwsInstance(nodeName string) (*awsInstance, error) {

// Implements Volumes.AttachDisk
func (aws *AWSCloud) AttachDisk(instanceName string, diskName string, readOnly bool) (string, error) {
disk, err := newAWSDisk(aws.ec2, diskName)
disk, err := newAWSDisk(aws, diskName)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -1316,7 +1319,7 @@ func (aws *AWSCloud) AttachDisk(instanceName string, diskName string, readOnly b

// Implements Volumes.DetachDisk
func (aws *AWSCloud) DetachDisk(instanceName string, diskName string) error {
disk, err := newAWSDisk(aws.ec2, diskName)
disk, err := newAWSDisk(aws, diskName)
if err != nil {
return err
}
Expand Down Expand Up @@ -1370,7 +1373,7 @@ func (aws *AWSCloud) CreateVolume(volumeOptions *VolumeOptions) (string, error)

// Implements Volumes.DeleteVolume
func (aws *AWSCloud) DeleteVolume(volumeName string) error {
awsDisk, err := newAWSDisk(aws.ec2, volumeName)
awsDisk, err := newAWSDisk(aws, volumeName)
if err != nil {
return err
}
Expand Down

0 comments on commit 736b3cb

Please sign in to comment.