String type instead of error type and changelog.

This commit is contained in:
Giulio Micheloni 2021-08-06 22:35:27 +01:00
parent 3a1afd8f57
commit 5c34a48d45
4 changed files with 8 additions and 4 deletions

3
.changelog/10612.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
acl: replication routine to report the last error message.
```

View File

@ -484,12 +484,12 @@ func (s *Server) IsACLReplicationEnabled() bool {
s.config.ACLTokenReplication s.config.ACLTokenReplication
} }
func (s *Server) updateACLReplicationStatusError(errorMsg error) { func (s *Server) updateACLReplicationStatusError(errorMsg string) {
s.aclReplicationStatusLock.Lock() s.aclReplicationStatusLock.Lock()
defer s.aclReplicationStatusLock.Unlock() defer s.aclReplicationStatusLock.Unlock()
s.aclReplicationStatus.LastError = time.Now().Round(time.Second).UTC() 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) { func (s *Server) updateACLReplicationStatusIndex(replicationType structs.ACLReplicationType, index uint64) {

View File

@ -810,7 +810,7 @@ func (s *Server) runLegacyACLReplication(ctx context.Context) error {
0, 0,
) )
lastRemoteIndex = 0 lastRemoteIndex = 0
s.updateACLReplicationStatusError(err) s.updateACLReplicationStatusError(err.Error())
legacyACLLogger.Warn("Legacy ACL replication error (will retry if still leader)", "error", err) legacyACLLogger.Warn("Legacy ACL replication error (will retry if still leader)", "error", err)
} else { } else {
metrics.SetGauge([]string{"leader", "replication", "acl-legacy", "status"}, metrics.SetGauge([]string{"leader", "replication", "acl-legacy", "status"},
@ -927,7 +927,7 @@ func (s *Server) runACLReplicator(
0, 0,
) )
lastRemoteIndex = 0 lastRemoteIndex = 0
s.updateACLReplicationStatusError(err) s.updateACLReplicationStatusError(err.Error())
logger.Warn("ACL replication error (will retry if still leader)", logger.Warn("ACL replication error (will retry if still leader)",
"error", err, "error", err,
) )

View File

@ -97,6 +97,7 @@ type ACLReplicationStatus struct {
ReplicatedTokenIndex uint64 ReplicatedTokenIndex uint64
LastSuccess time.Time LastSuccess time.Time
LastError time.Time LastError time.Time
LastErrorMessage string
} }
// ACLServiceIdentity represents a high-level grant of all necessary privileges // ACLServiceIdentity represents a high-level grant of all necessary privileges