From 843e2bd9b63872d18ff0cfbe6e121aeb1a4d3076 Mon Sep 17 00:00:00 2001 From: Juan Font Date: Sat, 30 Apr 2022 14:47:16 +0000 Subject: [PATCH 1/2] Do not setLastStateChangeToNow every 5 seconds --- app.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app.go b/app.go index b87fb33c..8a434363 100644 --- a/app.go +++ b/app.go @@ -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") @@ -311,7 +313,9 @@ func (h *Headscale) expireEphemeralNodesWorker() { } } - h.setLastStateChangeToNow(namespace.Name) + if expiredFound { + h.setLastStateChangeToNow(namespace.Name) + } } } From 03659c417507149df7dc294669077ad713063e6a Mon Sep 17 00:00:00 2001 From: Juan Font Date: Sat, 30 Apr 2022 14:50:55 +0000 Subject: [PATCH 2/2] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 359ace64..a9054927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Headscale fails to serve if the ACL policy file cannot be parsed [#537](https://github.com/juanfont/headscale/pull/537) - Fix labels cardinality error when registering unknown pre-auth key [#519](https://github.com/juanfont/headscale/pull/519) - Fix send on closed channel crash in polling [#542](https://github.com/juanfont/headscale/pull/542) +- Fixed spurious calls to setLastStateChangeToNow from ephemeral nodes [#566](https://github.com/juanfont/headscale/pull/566) ## 0.15.0 (2022-03-20)