~rogpeppe/juju-core/azure

« back to all changes in this revision

Viewing changes to environs/polling.go

[r=gz] Check correct info attr in cloudinit.apiHostAddrs

Fixes a copy/paste error in cloudinit.MachineConfig to agent.Conf
conversion helper function. No test as the only codepath that uses
this goes through verifyConfig which already asserts both StateInfo
and APIInfo are not nil, so not possible to write a failing test
using exposed functions.

Show diffs side-by-side

added added

removed removed

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