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

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/state/machine.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:
486
486
                C:      machinesC,
487
487
                Id:     m.doc.DocID,
488
488
                Assert: bson.D{{"jobs", bson.D{{"$nin", []MachineJob{JobManageModel}}}}},
489
 
        }, m.st.newCleanupOp(cleanupForceDestroyedMachine, m.doc.Id)}, nil
 
489
        }, newCleanupOp(cleanupForceDestroyedMachine, m.doc.Id)}, nil
490
490
}
491
491
 
492
492
// EnsureDead sets the machine lifecycle to Dead if it is Alive or Dying.
623
623
                        {{"principals", bson.D{{"$exists", false}}}},
624
624
                },
625
625
        }
626
 
        cleanupOp := m.st.newCleanupOp(cleanupDyingMachine, m.doc.Id)
 
626
        cleanupOp := newCleanupOp(cleanupDyingMachine, m.doc.Id)
627
627
        // multiple attempts: one with original data, one with refreshed data, and a final
628
628
        // one intended to determine the cause of failure of the preceding attempt.
629
629
        buildTxn := func(attempt int) ([]txn.Op, error) {
1526
1526
// SetStatus sets the status of the machine.
1527
1527
func (m *Machine) SetStatus(statusInfo status.StatusInfo) error {
1528
1528
        switch statusInfo.Status {
1529
 
        case status.StatusStarted, status.StatusStopped:
1530
 
        case status.StatusError:
 
1529
        case status.Started, status.Stopped:
 
1530
        case status.Error:
1531
1531
                if statusInfo.Message == "" {
1532
1532
                        return errors.Errorf("cannot set status %q without info", statusInfo.Status)
1533
1533
                }
1534
 
        case status.StatusPending:
 
1534
        case status.Pending:
1535
1535
                // If a machine is not yet provisioned, we allow its status
1536
1536
                // to be set back to pending (when a retry is to occur).
1537
1537
                _, err := m.InstanceId()
1540
1540
                        break
1541
1541
                }
1542
1542
                fallthrough
1543
 
        case status.StatusDown:
 
1543
        case status.Down:
1544
1544
                return errors.Errorf("cannot set status %q", statusInfo.Status)
1545
1545
        default:
1546
1546
                return errors.Errorf("cannot set invalid status %q", statusInfo.Status)
1656
1656
                                logger.Errorf("finding status of container %v to mark as invalid: %v", containerId, err)
1657
1657
                                continue
1658
1658
                        }
1659
 
                        if statusInfo.Status == status.StatusPending {
 
1659
                        if statusInfo.Status == status.Pending {
1660
1660
                                containerType := ContainerTypeFromId(containerId)
1661
 
                                // TODO(perrito666) 2016-05-02 lp:1558657
1662
 
                                now := time.Now()
 
1661
                                now := m.st.clock.Now()
1663
1662
                                s := status.StatusInfo{
1664
 
                                        Status:  status.StatusError,
 
1663
                                        Status:  status.Error,
1665
1664
                                        Message: "unsupported container",
1666
1665
                                        Data:    map[string]interface{}{"type": containerType},
1667
1666
                                        Since:   &now,