diff --git a/machine.go b/machine.go index 3f379093..d1ef246c 100644 --- a/machine.go +++ b/machine.go @@ -362,9 +362,9 @@ func (h *Headscale) GetMachineByMachineKey( return &m, nil } -// UpdateMachine takes a Machine struct pointer (typically already loaded from database +// UpdateMachineFromDatabase takes a Machine struct pointer (typically already loaded from database // and updates it with the latest data from the database. -func (h *Headscale) UpdateMachine(machine *Machine) error { +func (h *Headscale) UpdateMachineFromDatabase(machine *Machine) error { if result := h.db.Find(machine).First(&machine); result.Error != nil { return result.Error } @@ -463,7 +463,7 @@ func (machine *Machine) GetHostInfo() tailcfg.Hostinfo { } func (h *Headscale) isOutdated(machine *Machine) bool { - if err := h.UpdateMachine(machine); err != nil { + if err := h.UpdateMachineFromDatabase(machine); err != nil { // It does not seem meaningful to propagate this error as the end result // will have to be that the machine has to be considered outdated. return true diff --git a/poll.go b/poll.go index dcadadfa..a74d857d 100644 --- a/poll.go +++ b/poll.go @@ -319,7 +319,7 @@ func (h *Headscale) PollNetMapStream( // TODO(kradalby): Abstract away all the database calls, this can cause race conditions // when an outdated machine object is kept alive, e.g. db is update from // command line, but then overwritten. - err = h.UpdateMachine(machine) + err = h.UpdateMachineFromDatabase(machine) if err != nil { log.Error(). Str("handler", "PollNetMapStream"). @@ -385,7 +385,7 @@ func (h *Headscale) PollNetMapStream( // TODO(kradalby): Abstract away all the database calls, this can cause race conditions // when an outdated machine object is kept alive, e.g. db is update from // command line, but then overwritten. - err = h.UpdateMachine(machine) + err = h.UpdateMachineFromDatabase(machine) if err != nil { log.Error(). Str("handler", "PollNetMapStream"). @@ -475,7 +475,7 @@ func (h *Headscale) PollNetMapStream( // TODO(kradalby): Abstract away all the database calls, this can cause race conditions // when an outdated machine object is kept alive, e.g. db is update from // command line, but then overwritten. - err = h.UpdateMachine(machine) + err = h.UpdateMachineFromDatabase(machine) if err != nil { log.Error(). Str("handler", "PollNetMapStream"). @@ -526,7 +526,7 @@ func (h *Headscale) PollNetMapStream( // TODO: Abstract away all the database calls, this can cause race conditions // when an outdated machine object is kept alive, e.g. db is update from // command line, but then overwritten. - err := h.UpdateMachine(machine) + err := h.UpdateMachineFromDatabase(machine) if err != nil { log.Error(). Str("handler", "PollNetMapStream").