Mark all namespaces to lastChange now

This commit is contained in:
Juan Font Alonso 2022-08-16 13:39:15 +02:00
parent eb461d0713
commit 0db7fc5ab7
3 changed files with 6 additions and 6 deletions

2
app.go
View file

@ -270,7 +270,7 @@ func (h *Headscale) expireEphemeralNodesWorker() {
} }
if expiredFound { if expiredFound {
h.setLastStateChangeToNow(namespace.Name) h.setLastStateChangeToNow()
} }
} }
} }

View file

@ -410,7 +410,7 @@ func (h *Headscale) SetTags(machine *Machine, tags []string) error {
if err := h.UpdateACLRules(); err != nil && !errors.Is(err, errEmptyPolicy) { if err := h.UpdateACLRules(); err != nil && !errors.Is(err, errEmptyPolicy) {
return err return err
} }
h.setLastStateChangeToNow(machine.Namespace.Name) h.setLastStateChangeToNow()
if err := h.db.Save(machine).Error; err != nil { if err := h.db.Save(machine).Error; err != nil {
return fmt.Errorf("failed to update tags for machine in the database: %w", err) return fmt.Errorf("failed to update tags for machine in the database: %w", err)
@ -424,7 +424,7 @@ func (h *Headscale) ExpireMachine(machine *Machine) error {
now := time.Now() now := time.Now()
machine.Expiry = &now machine.Expiry = &now
h.setLastStateChangeToNow(machine.Namespace.Name) h.setLastStateChangeToNow()
if err := h.db.Save(machine).Error; err != nil { if err := h.db.Save(machine).Error; err != nil {
return fmt.Errorf("failed to expire machine in the database: %w", err) return fmt.Errorf("failed to expire machine in the database: %w", err)
@ -451,7 +451,7 @@ func (h *Headscale) RenameMachine(machine *Machine, newName string) error {
} }
machine.GivenName = newName machine.GivenName = newName
h.setLastStateChangeToNow(machine.Namespace.Name) h.setLastStateChangeToNow()
if err := h.db.Save(machine).Error; err != nil { if err := h.db.Save(machine).Error; err != nil {
return fmt.Errorf("failed to rename machine in the database: %w", err) return fmt.Errorf("failed to rename machine in the database: %w", err)
@ -467,7 +467,7 @@ func (h *Headscale) RefreshMachine(machine *Machine, expiry time.Time) error {
machine.LastSuccessfulUpdate = &now machine.LastSuccessfulUpdate = &now
machine.Expiry = &expiry machine.Expiry = &expiry
h.setLastStateChangeToNow(machine.Namespace.Name) h.setLastStateChangeToNow()
if err := h.db.Save(machine).Error; err != nil { if err := h.db.Save(machine).Error; err != nil {
return fmt.Errorf( return fmt.Errorf(

View file

@ -125,7 +125,7 @@ func (h *Headscale) handlePollCommon(
// There has been an update to _any_ of the nodes that the other nodes would // There has been an update to _any_ of the nodes that the other nodes would
// need to know about // need to know about
h.setLastStateChangeToNow(machine.Namespace.Name) h.setLastStateChangeToNow()
// The request is not ReadOnly, so we need to set up channels for updating // The request is not ReadOnly, so we need to set up channels for updating
// peers via longpoll // peers via longpoll