From 33d1a5565df1b68127a4d1fb431691a8c634469e Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 5 May 2021 17:37:02 -0400 Subject: [PATCH] agent/local: only use agent token for deletes --- agent/local/state.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/agent/local/state.go b/agent/local/state.go index 5eb396d1bc73..a3e0617e0621 100644 --- a/agent/local/state.go +++ b/agent/local/state.go @@ -239,8 +239,7 @@ func (l *State) ServiceToken(id structs.ServiceID) string { } // aclTokenForServiceSync returns an ACL token associated with a service. If there is -// no ACL token associated with the service, falls back to the agent token, then to the -// user default token. +// no ACL token associated with the service, falls back to to the user default token. // This method is not synchronized and the lock must already be held. func (l *State) aclTokenForServiceSync(id structs.ServiceID) string { var token string @@ -248,7 +247,7 @@ func (l *State) aclTokenForServiceSync(id structs.ServiceID) string { token = s.Token } if token == "" { - token = l.tokens.AgentToken() + token = l.tokens.UserToken() } return token } @@ -457,8 +456,7 @@ func (l *State) CheckToken(id structs.CheckID) string { } // aclTokenForCheckSync returns an ACL token associated with a check. If there is -// no ACL token associated with the check, falls back to the agent token, then to the -// user default token. +// no ACL token associated with the check, falls back to the the user default token. // This method is not synchronized and the lock must already be held. func (l *State) aclTokenForCheckSync(id structs.CheckID) string { var token string @@ -467,7 +465,7 @@ func (l *State) aclTokenForCheckSync(id structs.CheckID) string { token = c.Token } if token == "" { - token = l.tokens.AgentToken() + token = l.tokens.UserToken() } return token } @@ -1142,8 +1140,7 @@ func (l *State) deleteService(key structs.ServiceID) error { return fmt.Errorf("ServiceID missing") } - st := l.aclTokenForServiceSync(key) - + st := l.tokens.AgentToken() req := structs.DeregisterRequest{ Datacenter: l.config.Datacenter, Node: l.config.NodeName, @@ -1192,7 +1189,7 @@ func (l *State) deleteCheck(key structs.CheckID) error { return fmt.Errorf("CheckID missing") } - ct := l.aclTokenForCheckSync(key) + ct := l.tokens.AgentToken() req := structs.DeregisterRequest{ Datacenter: l.config.Datacenter, Node: l.config.NodeName,