1
// Copyright 2013 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
10
"launchpad.net/juju-core/instance"
11
"launchpad.net/juju-core/utils"
14
// Use ShortAttempt to poll for short-term events.
15
// TODO: This may need tuning for different providers (or even environments).
16
var ShortAttempt = utils.AttemptStrategy{
17
Total: 5 * time.Second,
18
Delay: 200 * time.Millisecond,
21
// A request may fail to due "eventual consistency" semantics, which
22
// should resolve fairly quickly. These delays are specific to the provider
23
// and best tuned there.
24
// Other requests fail due to a slow state transition (e.g. an instance taking
25
// a while to release a security group after termination). If you need to
26
// poll for the latter kind, use LongAttempt.
27
var LongAttempt = utils.AttemptStrategy{
28
Total: 3 * time.Minute,
29
Delay: 1 * time.Second,
32
// WaitDNSName is an implementation that the providers can use. It builds on
33
// the provider's implementation of Instance.DNSName.
34
func WaitDNSName(inst instance.Instance) (string, error) {
35
for a := LongAttempt.Start(); a.Next(); {
36
name, err := inst.DNSName()
37
if err == nil || err != instance.ErrNoDNSName {
41
return "", fmt.Errorf("timed out trying to get DNS address for %v", inst.Id())