Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
glide.lock
.site/
site/
.build/*/
.build/*-filtered.json
vendor/
.project

# Created by https://www.gitignore.io
Expand Down
29 changes: 26 additions & 3 deletions drivers/storage/ec2/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/akutz/gofig"
"github.com/akutz/goof"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds"
"github.com/aws/aws-sdk-go/aws/ec2metadata"
Expand Down Expand Up @@ -480,12 +481,17 @@ func (d *driver) createVolume(

d.createVolumeEnsureAvailabilityZone(&availabilityZone, &server)

// only forward iops if it's non-zero
var iops *int64
if IOPS > 0 {
iops = &IOPS
}
options := &ec2.CreateVolumeInput{
Size: &size,
SnapshotId: &snapshotID,
AvailabilityZone: &availabilityZone,
VolumeType: &volumeType,
Iops: &IOPS,
Iops: iops,
}

var resp *ec2.Volume
Expand Down Expand Up @@ -517,6 +523,12 @@ func (d *driver) createVolumeCreateSnapshot(
return "", err
}

err = d.waitSnapshotComplete(snapshots[0].SnapshotID)

if err != nil {
return "", err
}

return snapshots[0].SnapshotID, nil
}

Expand All @@ -532,8 +544,9 @@ func (d *driver) createVolumeCreateVolume(
for {
resp, err = d.ec2Instance.CreateVolume(options)
if err != nil {
if err.Error() ==
"Snapshot is in invalid state - pending (IncorrectState)" {
if awsErrMessage(err) ==
"Snapshot is in invalid state - pending" {
// Really, snapshot should be created already
time.Sleep(1 * time.Second)
continue
}
Expand Down Expand Up @@ -713,6 +726,9 @@ func (d *driver) waitSnapshotComplete(snapshotID string) error {
if *snapshot.State == ec2.SnapshotStateCompleted {
break
}
if *snapshot.State == ec2.SnapshotStateError {
return fmt.Errorf("%s", *snapshot.StateMessage)
}
time.Sleep(1 * time.Second)
}

Expand Down Expand Up @@ -1008,3 +1024,10 @@ func configRegistration() *gofig.Registration {
r.Key(gofig.String, "", "", "", "aws.region")
return r
}

func awsErrMessage(err error) string {
if awsErr, ok := err.(awserr.Error); ok {
return awsErr.Message()
}
return ""
}
220 changes: 220 additions & 0 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/github.com/BurntSushi/toml/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions vendor/github.com/BurntSushi/toml/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/github.com/BurntSushi/toml/COMPATIBLE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions vendor/github.com/BurntSushi/toml/COPYING

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions vendor/github.com/BurntSushi/toml/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading