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

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/state/allwatcher.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:
6
6
import (
7
7
        "reflect"
8
8
        "strings"
9
 
        "time"
10
9
 
11
10
        "github.com/juju/errors"
12
11
        "gopkg.in/juju/names.v2"
423
422
                        // Not sure how status can even return NotFound as it is created
424
423
                        // with the application initially. For now, we'll log the error as per
425
424
                        // the above and return Unknown.
426
 
                        // TODO(fwereade): 2016-03-17 lp:1558657
427
 
                        now := time.Now()
 
425
                        now := st.clock.Now()
428
426
                        info.Status = multiwatcher.StatusInfo{
429
 
                                Current: status.StatusUnknown,
 
427
                                Current: status.Unknown,
430
428
                                Since:   &now,
431
429
                                Data:    normaliseStatusData(nil),
432
430
                        }
648
646
        // Unit or workload status - display the agent status or any error.
649
647
        // NOTE: thumper 2016-06-27, this is truely horrible, and we are lying to our users.
650
648
        // however, this is explicitly what has been asked for as much as we dislike it.
651
 
        if strings.HasSuffix(id, "#charm") || s.Status == status.StatusError {
 
649
        if strings.HasSuffix(id, "#charm") || s.Status == status.Error {
652
650
                newInfo.WorkloadStatus = s.toStatusInfo()
653
651
        } else {
654
652
                newInfo.AgentStatus = s.toStatusInfo()
655
653
                // If the unit was in error and now it's not, we need to reset its
656
654
                // status back to what was previously recorded.
657
 
                if newInfo.WorkloadStatus.Current == status.StatusError {
 
655
                if newInfo.WorkloadStatus.Current == status.Error {
658
656
                        newInfo.WorkloadStatus.Current = unitStatus.Status
659
657
                        newInfo.WorkloadStatus.Message = unitStatus.Message
660
658
                        newInfo.WorkloadStatus.Data = unitStatus.Data