agent: check state is purged if expired

pull/1009/head
Ryan Uber 10 years ago
parent 2ee8fa8e15
commit 1636a35289

@ -938,7 +938,7 @@ func (a *Agent) recallCheckState(check *structs.HealthCheck) error {
// Check if the state has expired
if time.Now().Unix() >= p.Expires {
a.logger.Printf("[DEBUG] agent: check state expired for %q, not restoring", check.CheckID)
return nil
return a.purgeCheckState(check.CheckID)
}
// Restore the fields from the state

@ -1350,7 +1350,7 @@ func TestAgent_loadChecks_checkFails(t *testing.T) {
}
}
func TestAgent_persistCheckStatus(t *testing.T) {
func TestAgent_persistCheckState(t *testing.T) {
config := nextConfig()
dir, agent := makeAgent(t, config)
defer os.RemoveAll(dir)
@ -1433,6 +1433,12 @@ func TestAgent_recallCheckState(t *testing.T) {
t.Fatalf("bad: %#v", health)
}
// Should have purged the state
file := filepath.Join(agent.config.DataDir, checksDir, stringHash("check1"))
if _, err := os.Stat(file); !os.IsNotExist(err) {
t.Fatalf("should have purged state")
}
// Set a TTL which will not expire before we check it
check.TTL = time.Minute
err = agent.persistCheckState(check, structs.HealthPassing, "yup")

Loading…
Cancel
Save