Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(57)

Unified Diff: state/apiserver/admin.go

Issue 103770044: apiserver/admin: fix incorrect (down) status
Patch Set: apiserver/admin: fix incorrect (down) status Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « state/addmachine.go ('k') | state/apiserver/client/api_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
}
« no previous file with comments | « state/addmachine.go ('k') | state/apiserver/client/api_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b