Skip to content

Commit

Permalink
Do not setLastStateChangeToNow every 5 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfont authored Apr 30, 2022
1 parent 28efd92 commit 843e2bd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,13 @@ func (h *Headscale) expireEphemeralNodesWorker() {
return
}

expiredFound := false
for _, machine := range machines {
if machine.AuthKey != nil && machine.LastSeen != nil &&
machine.AuthKey.Ephemeral &&
time.Now().
After(machine.LastSeen.Add(h.cfg.EphemeralNodeInactivityTimeout)) {
expiredFound = true
log.Info().
Str("machine", machine.Name).
Msg("Ephemeral client removed from database")
Expand All @@ -311,7 +313,9 @@ func (h *Headscale) expireEphemeralNodesWorker() {
}
}

h.setLastStateChangeToNow(namespace.Name)
if expiredFound {
h.setLastStateChangeToNow(namespace.Name)
}
}
}

Expand Down

0 comments on commit 843e2bd

Please sign in to comment.