OLD | NEW |
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 "os" | 8 "os" |
9 "path/filepath" | 9 "path/filepath" |
10 "time" | 10 "time" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 case params.JobManageEnviron: | 207 case params.JobManageEnviron: |
208 runner.StartWorker("environ-provisioner", func() (worker
.Worker, error) { | 208 runner.StartWorker("environ-provisioner", func() (worker
.Worker, error) { |
209 return provisioner.NewEnvironProvisioner(st.Prov
isioner(), agentConfig), nil | 209 return provisioner.NewEnvironProvisioner(st.Prov
isioner(), agentConfig), nil |
210 }) | 210 }) |
211 // TODO(axw) 2013-09-24 bug #1229506 | 211 // TODO(axw) 2013-09-24 bug #1229506 |
212 // Make another job to enable the firewaller. Not all en
vironments | 212 // Make another job to enable the firewaller. Not all en
vironments |
213 // are capable of managing ports centrally. | 213 // are capable of managing ports centrally. |
214 runner.StartWorker("firewaller", func() (worker.Worker,
error) { | 214 runner.StartWorker("firewaller", func() (worker.Worker,
error) { |
215 return firewaller.NewFirewaller(st.Firewaller()) | 215 return firewaller.NewFirewaller(st.Firewaller()) |
216 }) | 216 }) |
217 case params.JobManageState: | |
218 runner.StartWorker("charm-revision-updater", func() (wor
ker.Worker, error) { | 217 runner.StartWorker("charm-revision-updater", func() (wor
ker.Worker, error) { |
219 return charmrevisionworker.NewRevisionUpdateWork
er(st.CharmRevisionUpdater()), nil | 218 return charmrevisionworker.NewRevisionUpdateWork
er(st.CharmRevisionUpdater()), nil |
220 }) | 219 }) |
| 220 case params.JobManageState: |
| 221 // Legacy environments may set this, but we ignore it. |
221 default: | 222 default: |
222 // TODO(dimitern): Once all workers moved over to using | 223 // TODO(dimitern): Once all workers moved over to using |
223 // the API, report "unknown job type" here. | 224 // the API, report "unknown job type" here. |
224 } | 225 } |
225 } | 226 } |
226 return newCloseWorker(runner, st), nil // Note: a worker.Runner is itsel
f a worker.Worker. | 227 return newCloseWorker(runner, st), nil // Note: a worker.Runner is itsel
f a worker.Worker. |
227 } | 228 } |
228 | 229 |
229 // setupContainerSupport determines what containers can be run on this machine a
nd | 230 // setupContainerSupport determines what containers can be run on this machine a
nd |
230 // initialises suitable infrastructure to support such containers. | 231 // initialises suitable infrastructure to support such containers. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 }) | 300 }) |
300 } | 301 } |
301 for _, job := range m.Jobs() { | 302 for _, job := range m.Jobs() { |
302 switch job { | 303 switch job { |
303 case state.JobHostUnits: | 304 case state.JobHostUnits: |
304 // Implemented in APIWorker. | 305 // Implemented in APIWorker. |
305 case state.JobManageEnviron: | 306 case state.JobManageEnviron: |
306 runner.StartWorker("instancepoller", func() (worker.Work
er, error) { | 307 runner.StartWorker("instancepoller", func() (worker.Work
er, error) { |
307 return instancepoller.NewWorker(st), nil | 308 return instancepoller.NewWorker(st), nil |
308 }) | 309 }) |
309 case state.JobManageState: | |
310 runner.StartWorker("apiserver", func() (worker.Worker, e
rror) { | 310 runner.StartWorker("apiserver", func() (worker.Worker, e
rror) { |
311 // If the configuration does not have the requir
ed information, | 311 // If the configuration does not have the requir
ed information, |
312 // it is currently not a recoverable error, so w
e kill the whole | 312 // it is currently not a recoverable error, so w
e kill the whole |
313 // agent, potentially enabling human interventio
n to fix | 313 // agent, potentially enabling human interventio
n to fix |
314 // the agent's configuration file. In the future
, we may retrieve | 314 // the agent's configuration file. In the future
, we may retrieve |
315 // the state server certificate and key from the
state, and | 315 // the state server certificate and key from the
state, and |
316 // this should then change. | 316 // this should then change. |
317 port, cert, key := a.Conf.config.APIServerDetail
s() | 317 port, cert, key := a.Conf.config.APIServerDetail
s() |
318 if len(cert) == 0 || len(key) == 0 { | 318 if len(cert) == 0 || len(key) == 0 { |
319 return nil, &fatalError{"configuration d
oes not have state server cert/key"} | 319 return nil, &fatalError{"configuration d
oes not have state server cert/key"} |
320 } | 320 } |
321 dataDir := a.Conf.config.DataDir() | 321 dataDir := a.Conf.config.DataDir() |
322 return apiserver.NewServer(st, fmt.Sprintf(":%d"
, port), cert, key, dataDir) | 322 return apiserver.NewServer(st, fmt.Sprintf(":%d"
, port), cert, key, dataDir) |
323 }) | 323 }) |
324 runner.StartWorker("cleaner", func() (worker.Worker, err
or) { | 324 runner.StartWorker("cleaner", func() (worker.Worker, err
or) { |
325 return cleaner.NewCleaner(st), nil | 325 return cleaner.NewCleaner(st), nil |
326 }) | 326 }) |
327 runner.StartWorker("resumer", func() (worker.Worker, err
or) { | 327 runner.StartWorker("resumer", func() (worker.Worker, err
or) { |
328 // The action of resumer is so subtle that it is
not tested, | 328 // The action of resumer is so subtle that it is
not tested, |
329 // because we can't figure out how to do so with
out brutalising | 329 // because we can't figure out how to do so with
out brutalising |
330 // the transaction log. | 330 // the transaction log. |
331 return resumer.NewResumer(st), nil | 331 return resumer.NewResumer(st), nil |
332 }) | 332 }) |
333 runner.StartWorker("minunitsworker", func() (worker.Work
er, error) { | 333 runner.StartWorker("minunitsworker", func() (worker.Work
er, error) { |
334 return minunitsworker.NewMinUnitsWorker(st), nil | 334 return minunitsworker.NewMinUnitsWorker(st), nil |
335 }) | 335 }) |
| 336 case state.JobManageState: |
| 337 // Legacy environments may set this, but we ignore it. |
336 default: | 338 default: |
337 logger.Warningf("ignoring unknown job %q", job) | 339 logger.Warningf("ignoring unknown job %q", job) |
338 } | 340 } |
339 } | 341 } |
340 return newCloseWorker(runner, st), nil | 342 return newCloseWorker(runner, st), nil |
341 } | 343 } |
342 | 344 |
343 func (a *MachineAgent) Entity(st *state.State) (AgentState, error) { | 345 func (a *MachineAgent) Entity(st *state.State) (AgentState, error) { |
344 m, err := st.Machine(a.MachineId) | 346 m, err := st.Machine(a.MachineId) |
345 if err != nil { | 347 if err != nil { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 select { | 438 select { |
437 case apiReporter <- st: | 439 case apiReporter <- st: |
438 default: | 440 default: |
439 } | 441 } |
440 } | 442 } |
441 func sendOpenedAPIs(dst chan<- *api.State) (undo func()) { | 443 func sendOpenedAPIs(dst chan<- *api.State) (undo func()) { |
442 var original chan<- *api.State | 444 var original chan<- *api.State |
443 original, apiReporter = apiReporter, dst | 445 original, apiReporter = apiReporter, dst |
444 return func() { apiReporter = original } | 446 return func() { apiReporter = original } |
445 } | 447 } |
OLD | NEW |