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

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/apiserver/common/unitstatus.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:
50
50
                // If the unit is in error, it would be bad to throw away
51
51
                // the error information as when the agent reconnects, that
52
52
                // error information would then be lost.
53
 
                if workload.Status.Status != status.StatusError {
54
 
                        workload.Status.Status = status.StatusUnknown
55
 
                        workload.Status.Message = fmt.Sprintf("agent lost, see 'juju status-history %s'", unit.Name())
 
53
                if workload.Status.Status != status.Error {
 
54
                        workload.Status.Status = status.Unknown
 
55
                        workload.Status.Message = fmt.Sprintf("agent lost, see 'juju show-status-log %s'", unit.Name())
56
56
                }
57
 
                agent.Status.Status = status.StatusLost
 
57
                agent.Status.Status = status.Lost
58
58
                agent.Status.Message = "agent is not communicating with the server"
59
59
        }
60
60
        return
62
62
 
63
63
func canBeLost(agent, workload status.StatusInfo) bool {
64
64
        switch agent.Status {
65
 
        case status.StatusAllocating:
 
65
        case status.Allocating:
66
66
                return false
67
 
        case status.StatusExecuting:
 
67
        case status.Executing:
68
68
                return agent.Message != operation.RunningHookMessage(string(hooks.Install))
69
69
        }
70
70
 
76
76
}
77
77
 
78
78
func isWorkloadInstalled(workload status.StatusInfo) bool {
79
 
        return workload.Status != status.StatusMaintenance || workload.Message != status.MessageInstalling
 
79
        switch workload.Status {
 
80
        case status.Maintenance:
 
81
                return workload.Message != status.MessageInstallingCharm
 
82
        case status.Waiting:
 
83
                switch workload.Message {
 
84
                case status.MessageWaitForMachine:
 
85
                case status.MessageInstallingAgent:
 
86
                case status.MessageInitializingAgent:
 
87
                        return false
 
88
                }
 
89
        }
 
90
        return true
80
91
}