Index: state/apiserver/admin.go |
=== modified file 'state/apiserver/admin.go' |
--- state/apiserver/admin.go 2014-05-20 08:02:01 +0000 |
+++ state/apiserver/admin.go 2014-06-02 13:23:35 +0000 |
@@ -6,6 +6,7 @@ |
import ( |
stderrors "errors" |
"sync" |
+ "time" |
"github.com/juju/errors" |
@@ -160,9 +161,15 @@ |
return p.Pinger.Kill() |
} |
+// waitPeriod is the amount of time we should wait for the machine agents presence. |
+// We use the waitPeriod with WaitAgentPresence. Without this the machine agent improperly |
+// reports itself as down for the duration of the "period" that is defined in state/presence. |
+var waitPeriod time.Duration = 5 |
+ |
func (a *srvAdmin) startPingerIfAgent(newRoot *srvRoot, entity taggedAuthenticator) error { |
- setAgentAliver, ok := entity.(interface { |
- SetAgentAlive() (*presence.Pinger, error) |
+ agentPresencer, ok := entity.(interface { |
+ SetAgentPresence() (*presence.Pinger, error) |
+ WaitAgentPresence(timeout time.Duration) error |
}) |
if !ok { |
return nil |
@@ -171,7 +178,7 @@ |
// announce it's now alive, and set up the API pinger |
// so that the connection will be terminated if a sufficient |
// interval passes between pings. |
- pinger, err := setAgentAliver.SetAgentAlive() |
+ pinger, err := agentPresencer.SetAgentPresence() |
if err != nil { |
return err |
} |
@@ -183,5 +190,7 @@ |
} |
pingTimeout := newPingTimeout(action, maxClientPingInterval) |
newRoot.resources.RegisterNamed("pingTimeout", pingTimeout) |
+ agentPresencer.WaitAgentPresence(waitPeriod) |
+ |
return nil |
} |