mirror of
https://github.com/juanfont/headscale.git
synced 2025-08-25 19:47:27 +00:00
Remove redundant caches
This commit removes the two extra caches (oidc, requested time) and uses the new central registration cache instead. The requested time is unified into the main machine object and the oidc key is just added to the same cache, as a string with the state as a key instead of machine key.
This commit is contained in:
17
grpcv1.go
17
grpcv1.go
@@ -160,25 +160,10 @@ func (api headscaleV1APIServer) RegisterMachine(
|
||||
Str("machine_key", request.GetKey()).
|
||||
Msg("Registering machine")
|
||||
|
||||
// TODO(kradalby): Currently, if it fails to find a requested expiry, non will be set
|
||||
// This means that if a user is to slow with register a machine, it will possibly not
|
||||
// have the correct expiry.
|
||||
requestedTime := time.Time{}
|
||||
if requestedTimeIf, found := api.h.requestedExpiryCache.Get(request.GetKey()); found {
|
||||
log.Trace().
|
||||
Caller().
|
||||
Str("machine", request.Key).
|
||||
Msg("Expiry time found in cache, assigning to node")
|
||||
if reqTime, ok := requestedTimeIf.(time.Time); ok {
|
||||
requestedTime = reqTime
|
||||
}
|
||||
}
|
||||
|
||||
machine, err := api.h.RegisterMachineFromAuthCallback(
|
||||
request.GetKey(),
|
||||
request.GetNamespace(),
|
||||
RegisterMethodCLI,
|
||||
&requestedTime,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -418,7 +403,7 @@ func (api headscaleV1APIServer) DebugCreateMachine(
|
||||
api.h.registrationCache.Set(
|
||||
request.GetKey(),
|
||||
newMachine,
|
||||
requestedExpiryCacheExpiration,
|
||||
registerCacheExpiration,
|
||||
)
|
||||
|
||||
return &v1.DebugCreateMachineResponse{Machine: newMachine.toProto()}, nil
|
||||
|
Reference in New Issue
Block a user