Fix unregistering agents used with agent tokens (#2870)

from discussion on matrix

I'm not sure if this is the best way to fix this, but I don't really see
a different way.
This commit is contained in:
qwerty287 2023-11-24 18:19:38 +01:00 committed by GitHub
parent a6d651175d
commit 111a0b4ea5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -352,6 +352,10 @@ func (s *RPC) RegisterAgent(ctx context.Context, platform, backend, version stri
func (s *RPC) UnregisterAgent(ctx context.Context) error {
agent, err := s.getAgentFromContext(ctx)
if agent.OwnerID > 0 {
// registered with individual agent token -> do not unregister
return nil
}
log.Debug().Msgf("unregistering agent with ID %d", agent.ID)
if err != nil {
return err