agent: check state is purged if expired
This commit is contained in:
parent
7d8993e0f0
commit
bd448d27fe
|
@ -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…
Reference in New Issue