~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/worker/uniter/uniter.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
256
256
                        // error state.
257
257
                        return nil
258
258
                }
259
 
                return setAgentStatus(u, status.StatusIdle, "", nil)
 
259
                return setAgentStatus(u, status.Idle, "", nil)
260
260
        }
261
261
 
262
262
        clearResolved := func() error {
335
335
                                // handling is outside of the resolver's control.
336
336
                                if operation.IsDeployConflictError(cause) {
337
337
                                        localState.Conflicted = true
338
 
                                        err = setAgentStatus(u, status.StatusError, "upgrade failed", nil)
 
338
                                        err = setAgentStatus(u, status.Error, "upgrade failed", nil)
339
339
                                } else {
340
340
                                        reportAgentError(u, "resolver loop error", err)
341
341
                                }
397
397
                // and inescapable, whereas this one is not.
398
398
                return worker.ErrTerminateAgent
399
399
        }
 
400
        // If initialising for the first time after deploying, update the status.
 
401
        currentStatus, err := u.unit.UnitStatus()
 
402
        if err != nil {
 
403
                return err
 
404
        }
 
405
        // TODO(fwereade/wallyworld): we should have an explicit place in the model
 
406
        // to tell us when we've hit this point, instead of piggybacking on top of
 
407
        // status and/or status history.
 
408
        // If the previous status was waiting for machine, we transition to the next step.
 
409
        if currentStatus.Status == string(status.Waiting) &&
 
410
                (currentStatus.Info == status.MessageWaitForMachine || currentStatus.Info == status.MessageInstallingAgent) {
 
411
                if err := u.unit.SetUnitStatus(status.Waiting, status.MessageInitializingAgent, nil); err != nil {
 
412
                        return errors.Trace(err)
 
413
                }
 
414
        }
400
415
        if err := jujuc.EnsureSymlinks(u.paths.ToolsDir); err != nil {
401
416
                return err
402
417
        }
421
436
        u.commands = runcommands.NewCommands()
422
437
        u.commandChannel = make(chan string)
423
438
 
 
439
        if err := charm.ClearDownloads(u.paths.State.BundlesDir); err != nil {
 
440
                logger.Warningf(err.Error())
 
441
        }
424
442
        deployer, err := charm.NewDeployer(
425
443
                u.paths.State.CharmDir,
426
444
                u.paths.State.DeployerDir,
547
565
        }
548
566
        statusData["hook"] = hookName
549
567
        statusMessage := fmt.Sprintf("hook failed: %q", hookName)
550
 
        return setAgentStatus(u, status.StatusError, statusMessage, statusData)
 
568
        return setAgentStatus(u, status.Error, statusMessage, statusData)
551
569
}