Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(446)

Side by Side Diff: worker/provisioner/provisioner.go

Issue 8561045: finish nonced provisioning (Closed)
Patch Set: Created 10 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 package provisioner 1 package provisioner
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "launchpad.net/juju-core/environs" 5 "launchpad.net/juju-core/environs"
6 "launchpad.net/juju-core/environs/config" 6 "launchpad.net/juju-core/environs/config"
7 "launchpad.net/juju-core/log" 7 "launchpad.net/juju-core/log"
8 "launchpad.net/juju-core/state" 8 "launchpad.net/juju-core/state"
9 "launchpad.net/juju-core/state/api" 9 "launchpad.net/juju-core/state/api"
10 "launchpad.net/juju-core/state/api/params" 10 "launchpad.net/juju-core/state/api/params"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // UAs to locate the state for this environment, it is logical to use th e same 263 // UAs to locate the state for this environment, it is logical to use th e same
264 // state.Info as the PA. 264 // state.Info as the PA.
265 stateInfo, apiInfo, err := p.setupAuthentication(m) 265 stateInfo, apiInfo, err := p.setupAuthentication(m)
266 if err != nil { 266 if err != nil {
267 return err 267 return err
268 } 268 }
269 cons, err := m.Constraints() 269 cons, err := m.Constraints()
270 if err != nil { 270 if err != nil {
271 return err 271 return err
272 } 272 }
273 » // TODO(dimitern) generate an unique random nonce in a follow-up. 273 » // Generate a unique nonce for the new instance.
274 » inst, err := p.environ.StartInstance(m.Id(), "fake_nonce", m.Series(), c ons, stateInfo, apiInfo) 274 » uuid, err := trivial.NewUUID()
275 » if err != nil {
276 » » return err
277 » }
278 » uniqueNonce := uuid.String()
fwereade 2013/04/09 21:27:21 Please badge this with the tag of the machine runn
dimitern 2013/04/10 12:36:40 As discussed, by passing the machine id to NewProv
279 » inst, err := p.environ.StartInstance(m.Id(), uniqueNonce, m.Series(), co ns, stateInfo, apiInfo)
275 if err != nil { 280 if err != nil {
276 // Set the state to error, so the machine will be skipped next 281 // Set the state to error, so the machine will be skipped next
277 // time until the error is resolved, but don't return an 282 // time until the error is resolved, but don't return an
278 // error; just keep going with the other machines. 283 // error; just keep going with the other machines.
279 log.Errorf("worker/provisioner: cannot start instance for machin e %q: %v", m, err) 284 log.Errorf("worker/provisioner: cannot start instance for machin e %q: %v", m, err)
280 if err1 := m.SetStatus(params.MachineError, err.Error()); err1 ! = nil { 285 if err1 := m.SetStatus(params.MachineError, err.Error()); err1 ! = nil {
281 // Something is wrong with this machine, better report i t back. 286 // Something is wrong with this machine, better report i t back.
282 log.Errorf("worker/provisioner: cannot set error status for machine %q: %v", m, err1) 287 log.Errorf("worker/provisioner: cannot set error status for machine %q: %v", m, err1)
283 return err1 288 return err1
284 } 289 }
285 return nil 290 return nil
286 } 291 }
287 » // TODO(dimitern) generate an unique random nonce in a follow-up. 292 » if err := m.SetProvisioned(inst.Id(), uniqueNonce); err != nil {
288 » if err := m.SetProvisioned(inst.Id(), ""); err != nil {
289 // The machine is started, but we can't record the mapping in 293 // The machine is started, but we can't record the mapping in
290 // state. It'll keep running while we fail out and restart, 294 // state. It'll keep running while we fail out and restart,
291 // but will then be detected by findUnknownInstances and 295 // but will then be detected by findUnknownInstances and
292 // killed again. 296 // killed again.
293 // 297 //
294 // Multiple instantiations of a given machine (with the same 298 // Multiple instantiations of a given machine (with the same
295 // machine ID) cannot coexist, because findUnknownInstances is 299 // machine ID) cannot coexist, because findUnknownInstances is
296 // called before startMachines. However, if the first machine 300 // called before startMachines. However, if the first machine
297 // had started to do work before being replaced, we may 301 // had started to do work before being replaced, we may
298 // encounter surprising problems. 302 // encounter surprising problems.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 if err == environs.ErrNoInstances { 375 if err == environs.ErrNoInstances {
372 continue 376 continue
373 } 377 }
374 if err != nil { 378 if err != nil {
375 return nil, err 379 return nil, err
376 } 380 }
377 insts = append(insts, inst) 381 insts = append(insts, inst)
378 } 382 }
379 return insts, nil 383 return insts, nil
380 } 384 }
OLDNEW
« trivial/uuid.go ('K') | « trivial/uuid.go ('k') | worker/provisioner/provisioner_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b