Commit b9bfae8d authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

amazon/chroot: style

parent 20fa7aee
...@@ -3,12 +3,13 @@ package chroot ...@@ -3,12 +3,13 @@ package chroot
import ( import (
"errors" "errors"
"fmt" "fmt"
"strings"
"time"
"github.com/mitchellh/goamz/ec2" "github.com/mitchellh/goamz/ec2"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
awscommon "github.com/mitchellh/packer/builder/amazon/common" awscommon "github.com/mitchellh/packer/builder/amazon/common"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"strings"
"time"
) )
// StepAttachVolume attaches the previously created volume to an // StepAttachVolume attaches the previously created volume to an
...@@ -51,7 +52,7 @@ func (s *StepAttachVolume) Run(state multistep.StateBag) multistep.StepAction { ...@@ -51,7 +52,7 @@ func (s *StepAttachVolume) Run(state multistep.StateBag) multistep.StepAction {
StepState: state, StepState: state,
Target: "attached", Target: "attached",
Refresh: func() (interface{}, string, error) { Refresh: func() (interface{}, string, error) {
var attempts = 0 attempts := 0
for attempts < 30 { for attempts < 30 {
resp, err := ec2conn.Volumes([]string{volumeId}, ec2.NewFilter()) resp, err := ec2conn.Volumes([]string{volumeId}, ec2.NewFilter())
if err != nil { if err != nil {
...@@ -63,11 +64,12 @@ func (s *StepAttachVolume) Run(state multistep.StateBag) multistep.StepAction { ...@@ -63,11 +64,12 @@ func (s *StepAttachVolume) Run(state multistep.StateBag) multistep.StepAction {
} }
// When Attachment on volume is not present sleep for 2s and retry // When Attachment on volume is not present sleep for 2s and retry
attempts += 1 attempts += 1
ui.Say( ui.Say(fmt.Sprintf(
fmt.Sprintf("Warning volume %s show no attachments, Attempt %d/30, Sleeping for 2s and will retry.", "Volume %s show no attachments. Attempt %d/30. Sleeping for 2s and will retry.",
volumeId, attempts)) volumeId, attempts))
time.Sleep(time.Duration(2) * time.Second) time.Sleep(2 * time.Second)
} }
// Attachment on volume is not present after all attempts // Attachment on volume is not present after all attempts
return nil, "", errors.New("No attachments on volume.") return nil, "", errors.New("No attachments on volume.")
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment