~rogpeppe/juju-core/387-use-testing-set

« back to all changes in this revision

Viewing changes to worker/upgrader/upgrader.go

  • Committer: Ian Booth
  • Date: 2013-08-21 05:38:38 UTC
  • mto: (1603.8.2 simplify-tools-search)
  • mto: This revision was merged to the branch mainline in revision 1702.
  • Revision ID: ian.booth@canonical.com-20130821053838-3c9oahds4mg2u0l7
Pull out Tools struct to its own package

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
        "launchpad.net/juju-core/agent/tools"
15
15
        "launchpad.net/juju-core/state/api/upgrader"
16
16
        "launchpad.net/juju-core/state/watcher"
 
17
        coretools "launchpad.net/juju-core/tools"
17
18
        "launchpad.net/juju-core/version"
18
19
)
19
20
 
27
28
// an upgrade is ready to be performed and a restart is due.
28
29
type UpgradeReadyError struct {
29
30
        AgentName string
30
 
        OldTools  *tools.Tools
31
 
        NewTools  *tools.Tools
 
31
        OldTools  *coretools.Tools
 
32
        NewTools  *coretools.Tools
32
33
        DataDir   string
33
34
}
34
35
 
40
41
// It should be called just before an agent exits, so that
41
42
// it will restart running the new tools.
42
43
func (e *UpgradeReadyError) ChangeAgentTools() error {
43
 
        tools, err := tools.ChangeAgentTools(e.DataDir, e.AgentName, e.NewTools.Version)
 
44
        agenttools, err := tools.ChangeAgentTools(e.DataDir, e.AgentName, e.NewTools.Version)
44
45
        if err != nil {
45
46
                return err
46
47
        }
47
 
        logger.Infof("upgraded from %v to %v (%q)", e.OldTools.Version, tools.Version, tools.URL)
 
48
        logger.Infof("upgraded from %v to %v (%q)", e.OldTools.Version, agenttools.Version, agenttools.URL)
48
49
        return nil
49
50
}
50
51
 
103
104
                // The problem should sort itself out as we will immediately
104
105
                // download some more tools and upgrade.
105
106
                logger.Warningf("cannot read current tools: %v", err)
106
 
                currentTools = &tools.Tools{
 
107
                currentTools = &coretools.Tools{
107
108
                        Version: version.Current,
108
109
                }
109
110
        }
123
124
        // that we attempt an upgrade even if other workers are dying
124
125
        // all around us.
125
126
        var dying <-chan struct{}
126
 
        var wantTools *tools.Tools
 
127
        var wantTools *coretools.Tools
127
128
        for {
128
129
                select {
129
130
                case _, ok := <-changes:
162
163
        }
163
164
}
164
165
 
165
 
func (u *Upgrader) fetchTools(agentTools *tools.Tools) error {
 
166
func (u *Upgrader) fetchTools(agentTools *coretools.Tools) error {
166
167
        logger.Infof("fetching tools from %q", agentTools.URL)
167
168
        resp, err := http.Get(agentTools.URL)
168
169
        if err != nil {