Skip to content

Commit

Permalink
Remove LastSuccessfulUpdate from Machine
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
kradalby committed Sep 19, 2023
1 parent 591ff8d commit 3bef63b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
5 changes: 1 addition & 4 deletions hscontrol/db/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions hscontrol/grpcv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
11 changes: 2 additions & 9 deletions hscontrol/types/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 3bef63b

Please sign in to comment.