From 3bef63bb807fcf89b5fe9c20b60d90932949a675 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Mon, 11 Sep 2023 06:23:29 -0500 Subject: [PATCH] Remove LastSuccessfulUpdate from Machine This field is no longer used, it was used in our old state "algorithm" to determine if we should send an update. Signed-off-by: Kristoffer Dalby --- hscontrol/db/machine.go | 5 +---- hscontrol/grpcv1.go | 5 ++--- hscontrol/types/machine.go | 11 ++--------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/hscontrol/db/machine.go b/hscontrol/db/machine.go index 60d93c98..3cf0465f 100644 --- a/hscontrol/db/machine.go +++ b/hscontrol/db/machine.go @@ -318,11 +318,8 @@ func (hsdb *HSDatabase) MachineSetExpiry(machine *types.Machine, expiry time.Tim } func (hsdb *HSDatabase) machineSetExpiry(machine *types.Machine, expiry time.Time) error { - now := time.Now() - if err := hsdb.db.Model(machine).Updates(types.Machine{ - LastSuccessfulUpdate: &now, - Expiry: &expiry, + Expiry: &expiry, }).Error; err != nil { return fmt.Errorf( "failed to refresh machine (update expiration) in the database: %w", diff --git a/hscontrol/grpcv1.go b/hscontrol/grpcv1.go index c9ab5168..d516ab94 100644 --- a/hscontrol/grpcv1.go +++ b/hscontrol/grpcv1.go @@ -532,9 +532,8 @@ func (api headscaleV1APIServer) DebugCreateMachine( GivenName: givenName, User: *user, - Expiry: &time.Time{}, - LastSeen: &time.Time{}, - LastSuccessfulUpdate: &time.Time{}, + Expiry: &time.Time{}, + LastSeen: &time.Time{}, HostInfo: types.HostInfo(hostinfo), } diff --git a/hscontrol/types/machine.go b/hscontrol/types/machine.go index 9a869021..534a0d13 100644 --- a/hscontrol/types/machine.go +++ b/hscontrol/types/machine.go @@ -53,9 +53,8 @@ type Machine struct { AuthKeyID uint AuthKey *PreAuthKey - LastSeen *time.Time - LastSuccessfulUpdate *time.Time - Expiry *time.Time + LastSeen *time.Time + Expiry *time.Time HostInfo HostInfo Endpoints StringList @@ -246,12 +245,6 @@ func (machine *Machine) Proto() *v1.Machine { machineProto.LastSeen = timestamppb.New(*machine.LastSeen) } - if machine.LastSuccessfulUpdate != nil { - machineProto.LastSuccessfulUpdate = timestamppb.New( - *machine.LastSuccessfulUpdate, - ) - } - if machine.Expiry != nil { machineProto.Expiry = timestamppb.New(*machine.Expiry) }