// ReportUnitState attaches the current state of the Agent's Machine to the given // unit.UnitState object, then persists that state in the Registry func (a *Agent) ReportUnitState(jobName string, us *unit.UnitState) { if us == nil { log.V(1).Infof("Job(%s): purging UnitState from Registry", jobName) err := a.registry.RemoveUnitState(jobName) if err != nil { log.Errorf("Failed to remove UnitState for job %s from Registry: %s", jobName, err.Error()) } } else { ms := a.Machine.State() us.MachineState = &ms log.V(1).Infof("Job(%s): pushing UnitState (loadState=%s, activeState=%s, subState=%s) to Registry", jobName, us.LoadState, us.ActiveState, us.SubState) a.registry.SaveUnitState(jobName, us) } }