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

Delta Between Two Patch Sets: worker/provisioner/provisioner.go

Issue 8620043: finish nonced provisioning (Closed)
Left Patch Set: Created 10 years, 11 months ago
Right Patch Set: finish nonced provisioning 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « trivial/uuid_test.go ('k') | worker/provisioner/provisioner_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 270 }
271 cons, err := m.Constraints() 271 cons, err := m.Constraints()
272 if err != nil { 272 if err != nil {
273 return err 273 return err
274 } 274 }
275 // Generate a unique nonce for the new instance. 275 // Generate a unique nonce for the new instance.
276 uuid, err := trivial.NewUUID() 276 uuid, err := trivial.NewUUID()
277 if err != nil { 277 if err != nil {
278 return err 278 return err
279 } 279 }
280 » uniqueNonce := fmt.Sprintf("%s:%s", state.MachineTag(p.machineId), uuid. String()) 280 » // Generated nonce has the format: "machine-#:UUID". The first
fwereade 2013/04/10 12:51:49 "unique" is implied by "nonce" -- can't we just us
TheMue 2013/04/10 12:59:34 Would like to see a little note about the reason o
dimitern 2013/04/10 13:49:01 Done.
dimitern 2013/04/10 13:49:01 Done.
281 » inst, err := p.environ.StartInstance(m.Id(), uniqueNonce, m.Series(), co ns, stateInfo, apiInfo) 281 » // part is a badge, specifying the tag of the machine the provisioner
282 » // is running on, while the second part is a random UUID.
283 » nonce := fmt.Sprintf("%s:%s", state.MachineTag(p.machineId), uuid.String ())
284 » inst, err := p.environ.StartInstance(m.Id(), nonce, m.Series(), cons, st ateInfo, apiInfo)
282 if err != nil { 285 if err != nil {
283 // Set the state to error, so the machine will be skipped next 286 // Set the state to error, so the machine will be skipped next
284 // time until the error is resolved, but don't return an 287 // time until the error is resolved, but don't return an
285 // error; just keep going with the other machines. 288 // error; just keep going with the other machines.
286 log.Errorf("worker/provisioner: cannot start instance for machin e %q: %v", m, err) 289 log.Errorf("worker/provisioner: cannot start instance for machin e %q: %v", m, err)
287 if err1 := m.SetStatus(params.MachineError, err.Error()); err1 ! = nil { 290 if err1 := m.SetStatus(params.MachineError, err.Error()); err1 ! = nil {
288 // Something is wrong with this machine, better report i t back. 291 // Something is wrong with this machine, better report i t back.
289 log.Errorf("worker/provisioner: cannot set error status for machine %q: %v", m, err1) 292 log.Errorf("worker/provisioner: cannot set error status for machine %q: %v", m, err1)
290 return err1 293 return err1
291 } 294 }
292 return nil 295 return nil
293 } 296 }
294 » if err := m.SetProvisioned(inst.Id(), uniqueNonce); err != nil { 297 » if err := m.SetProvisioned(inst.Id(), nonce); err != nil {
295 // The machine is started, but we can't record the mapping in 298 // The machine is started, but we can't record the mapping in
296 // state. It'll keep running while we fail out and restart, 299 // state. It'll keep running while we fail out and restart,
297 // but will then be detected by findUnknownInstances and 300 // but will then be detected by findUnknownInstances and
298 // killed again. 301 // killed again.
299 // 302 //
300 // TODO(dimitern) Stop the instance right away here. 303 // TODO(dimitern) Stop the instance right away here.
301 // 304 //
302 // Multiple instantiations of a given machine (with the same 305 // Multiple instantiations of a given machine (with the same
303 // machine ID) cannot coexist, because findUnknownInstances is 306 // machine ID) cannot coexist, because findUnknownInstances is
304 // called before startMachines. However, if the first machine 307 // called before startMachines. However, if the first machine
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 if err == environs.ErrNoInstances { 382 if err == environs.ErrNoInstances {
380 continue 383 continue
381 } 384 }
382 if err != nil { 385 if err != nil {
383 return nil, err 386 return nil, err
384 } 387 }
385 insts = append(insts, inst) 388 insts = append(insts, inst)
386 } 389 }
387 return insts, nil 390 return insts, nil
388 } 391 }
LEFTRIGHT

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