LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2012, 2013 Canonical Ltd. | 1 // Copyright 2012, 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package main | 4 package main |
5 | 5 |
6 import ( | 6 import ( |
7 "fmt" | 7 "fmt" |
8 "io" | 8 "io" |
9 "time" | 9 "time" |
10 | 10 |
11 "launchpad.net/gnuflag" | 11 "launchpad.net/gnuflag" |
12 | 12 |
13 "launchpad.net/juju-core/agent" | 13 "launchpad.net/juju-core/agent" |
14 "launchpad.net/juju-core/cmd" | 14 "launchpad.net/juju-core/cmd" |
15 "launchpad.net/juju-core/errors" | 15 "launchpad.net/juju-core/errors" |
16 "launchpad.net/juju-core/log" | |
17 "launchpad.net/juju-core/state" | 16 "launchpad.net/juju-core/state" |
18 "launchpad.net/juju-core/state/api" | 17 "launchpad.net/juju-core/state/api" |
19 apiagent "launchpad.net/juju-core/state/api/agent" | 18 apiagent "launchpad.net/juju-core/state/api/agent" |
20 apideployer "launchpad.net/juju-core/state/api/deployer" | 19 apideployer "launchpad.net/juju-core/state/api/deployer" |
21 "launchpad.net/juju-core/state/api/params" | 20 "launchpad.net/juju-core/state/api/params" |
22 "launchpad.net/juju-core/version" | 21 "launchpad.net/juju-core/version" |
23 "launchpad.net/juju-core/worker" | 22 "launchpad.net/juju-core/worker" |
24 "launchpad.net/juju-core/worker/deployer" | 23 "launchpad.net/juju-core/worker/deployer" |
25 "launchpad.net/juju-core/worker/upgrader" | 24 "launchpad.net/juju-core/worker/upgrader" |
26 ) | 25 ) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // connectionIsFatal returns a function suitable for passing | 118 // connectionIsFatal returns a function suitable for passing |
120 // as the isFatal argument to worker.NewRunner, | 119 // as the isFatal argument to worker.NewRunner, |
121 // that diagnoses an error as fatal if the connection | 120 // that diagnoses an error as fatal if the connection |
122 // has failed or if the error is otherwise fatal. | 121 // has failed or if the error is otherwise fatal. |
123 func connectionIsFatal(conn pinger) func(err error) bool { | 122 func connectionIsFatal(conn pinger) func(err error) bool { |
124 return func(err error) bool { | 123 return func(err error) bool { |
125 if isFatal(err) { | 124 if isFatal(err) { |
126 return true | 125 return true |
127 } | 126 } |
128 if err := conn.Ping(); err != nil { | 127 if err := conn.Ping(); err != nil { |
129 » » » log.Infof("error pinging %T: %v", conn, err) | 128 » » » logger.Infof("error pinging %T: %v", conn, err) |
130 return true | 129 return true |
131 } | 130 } |
132 return false | 131 return false |
133 } | 132 } |
134 } | 133 } |
135 | 134 |
136 // isleep waits for the given duration or until it receives a value on | 135 // isleep waits for the given duration or until it receives a value on |
137 // stop. It returns whether the full duration was slept without being | 136 // stop. It returns whether the full duration was slept without being |
138 // stopped. | 137 // stopped. |
139 func isleep(d time.Duration, stop <-chan struct{}) bool { | 138 func isleep(d time.Duration, stop <-chan struct{}) bool { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 220 } |
222 } | 221 } |
223 | 222 |
224 func (c *closeWorker) Kill() { | 223 func (c *closeWorker) Kill() { |
225 c.worker.Kill() | 224 c.worker.Kill() |
226 } | 225 } |
227 | 226 |
228 func (c *closeWorker) Wait() error { | 227 func (c *closeWorker) Wait() error { |
229 err := c.worker.Wait() | 228 err := c.worker.Wait() |
230 if err := c.closer.Close(); err != nil { | 229 if err := c.closer.Close(); err != nil { |
231 » » log.Errorf("closeWorker: close error: %v", err) | 230 » » logger.Errorf("closeWorker: close error: %v", err) |
232 } | 231 } |
233 return err | 232 return err |
234 } | 233 } |
235 | 234 |
236 // newDeployContext gives the tests the opportunity to create a deployer.Context | 235 // newDeployContext gives the tests the opportunity to create a deployer.Context |
237 // that can be used for testing so as to avoid (1) deploying units to the system | 236 // that can be used for testing so as to avoid (1) deploying units to the system |
238 // running the tests and (2) get access to the *State used internally, so that | 237 // running the tests and (2) get access to the *State used internally, so that |
239 // tests can be run without waiting for the 5s watcher refresh time to which we
would | 238 // tests can be run without waiting for the 5s watcher refresh time to which we
would |
240 // otherwise be restricted. | 239 // otherwise be restricted. |
241 var newDeployContext = func(st *apideployer.State, agentConfig agent.Config) dep
loyer.Context { | 240 var newDeployContext = func(st *apideployer.State, agentConfig agent.Config) dep
loyer.Context { |
242 return deployer.NewSimpleContext(agentConfig, st) | 241 return deployer.NewSimpleContext(agentConfig, st) |
243 } | 242 } |
LEFT | RIGHT |