Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #351 from bcwaldon/manual-refresh-state
Browse files Browse the repository at this point in the history
Explain why we manually publish state
  • Loading branch information
bcwaldon committed Apr 19, 2014
2 parents c0cfbff + 50bbd56 commit 19aaad2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,14 @@ func (a *Agent) LoadJob(j *job.Job) {

a.systemd.LoadJob(j)

//TODO(bcwaldon): Investigate whether or not this manual
// fetching of the payload state is necessary.
// We must explicitly refresh the payload state, as the dbus
// event listener does not send an event when we write a unit
// file to disk.
ps, err := a.systemd.GetPayloadState(j.Name)
if err != nil {
log.Errorf("Failed fetching state of Job(%s)", j.Name)
log.Errorf("Failed fetching state of Payload(%s)", j.Name)
return
}

a.ReportPayloadState(j.Name, ps)
}

Expand Down Expand Up @@ -274,6 +274,10 @@ func (a *Agent) UnloadJob(jobName string) {

a.ForgetJob(jobName)
a.systemd.UnloadJob(jobName)

// The dbus event systemd will not trigger an event telling
// us that the unit has been unloaded, so we must explicitly
// clear what is in the Registry.
a.ReportPayloadState(jobName, nil)

// Trigger rescheduling of all the peers of the job that was just unloaded
Expand Down

0 comments on commit 19aaad2

Please sign in to comment.