diff --git a/.changelog/23383.txt b/.changelog/23383.txt new file mode 100644 index 00000000000..6d48f92f869 --- /dev/null +++ b/.changelog/23383.txt @@ -0,0 +1,3 @@ +```release-note:bug +server: Fixed a bug where expiring heartbeats for garbage collected nodes could panic the server +``` diff --git a/nomad/heartbeat.go b/nomad/heartbeat.go index 2b207b6ed41..6b394811843 100644 --- a/nomad/heartbeat.go +++ b/nomad/heartbeat.go @@ -183,6 +183,10 @@ func (h *nodeHeartbeater) disconnectState(id string) (bool, bool) { h.logger.Error("error retrieving node by id", "error", err) return false, false } + if node == nil { + h.logger.Error("node not found", "node_id", id) + return false, false + } // Exit if the node is already down or just initializing. if node.Status == structs.NodeStatusDown || node.Status == structs.NodeStatusInit {