From 5c34a48d45ff44a0cd4b51e339bc34cf5c0a268b Mon Sep 17 00:00:00 2001 From: Giulio Micheloni Date: Fri, 6 Aug 2021 22:35:27 +0100 Subject: [PATCH] String type instead of error type and changelog. --- .changelog/10612.txt | 3 +++ agent/consul/acl_replication.go | 4 ++-- agent/consul/leader.go | 4 ++-- api/acl.go | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .changelog/10612.txt diff --git a/.changelog/10612.txt b/.changelog/10612.txt new file mode 100644 index 000000000..e9a54002d --- /dev/null +++ b/.changelog/10612.txt @@ -0,0 +1,3 @@ +```release-note:improvement +acl: replication routine to report the last error message. +``` diff --git a/agent/consul/acl_replication.go b/agent/consul/acl_replication.go index 6c5d07f31..2fa89f0f5 100644 --- a/agent/consul/acl_replication.go +++ b/agent/consul/acl_replication.go @@ -484,12 +484,12 @@ func (s *Server) IsACLReplicationEnabled() bool { s.config.ACLTokenReplication } -func (s *Server) updateACLReplicationStatusError(errorMsg error) { +func (s *Server) updateACLReplicationStatusError(errorMsg string) { s.aclReplicationStatusLock.Lock() defer s.aclReplicationStatusLock.Unlock() s.aclReplicationStatus.LastError = time.Now().Round(time.Second).UTC() - s.aclReplicationStatus.LastErrorMessage = errorMsg.Error() + s.aclReplicationStatus.LastErrorMessage = errorMsg } func (s *Server) updateACLReplicationStatusIndex(replicationType structs.ACLReplicationType, index uint64) { diff --git a/agent/consul/leader.go b/agent/consul/leader.go index c5c35b790..230b9f5a7 100644 --- a/agent/consul/leader.go +++ b/agent/consul/leader.go @@ -810,7 +810,7 @@ func (s *Server) runLegacyACLReplication(ctx context.Context) error { 0, ) lastRemoteIndex = 0 - s.updateACLReplicationStatusError(err) + s.updateACLReplicationStatusError(err.Error()) legacyACLLogger.Warn("Legacy ACL replication error (will retry if still leader)", "error", err) } else { metrics.SetGauge([]string{"leader", "replication", "acl-legacy", "status"}, @@ -927,7 +927,7 @@ func (s *Server) runACLReplicator( 0, ) lastRemoteIndex = 0 - s.updateACLReplicationStatusError(err) + s.updateACLReplicationStatusError(err.Error()) logger.Warn("ACL replication error (will retry if still leader)", "error", err, ) diff --git a/api/acl.go b/api/acl.go index d94c2807a..e0072e9b0 100644 --- a/api/acl.go +++ b/api/acl.go @@ -97,6 +97,7 @@ type ACLReplicationStatus struct { ReplicatedTokenIndex uint64 LastSuccess time.Time LastError time.Time + LastErrorMessage string } // ACLServiceIdentity represents a high-level grant of all necessary privileges