acl: fix error type into a string type for serialization issue

acl_endpoint_test.go:507:
        	Error Trace:	acl_endpoint_test.go:507
        	            				retry.go:148
        	            				retry.go:149
        	            				retry.go:103
        	            				acl_endpoint_test.go:504
        	Error:      	Received unexpected error:
        	            	codec.decoder: decodeValue: Cannot decode non-nil codec value into nil error (1 methods)
        	Test:       	TestACLEndpoint_ReplicationStatus
This commit is contained in:
Giulio Micheloni 2021-07-15 11:31:44 +02:00
parent 96fe1f4078
commit 3a1afd8f57
3 changed files with 3 additions and 4 deletions

View File

@ -489,7 +489,7 @@ func (s *Server) updateACLReplicationStatusError(errorMsg error) {
defer s.aclReplicationStatusLock.Unlock()
s.aclReplicationStatus.LastError = time.Now().Round(time.Second).UTC()
s.aclReplicationStatus.LastErrorMessage = errorMsg
s.aclReplicationStatus.LastErrorMessage = errorMsg.Error()
}
func (s *Server) updateACLReplicationStatusIndex(replicationType structs.ACLReplicationType, index uint64) {

View File

@ -1,7 +1,6 @@
package consul
import (
"errors"
"fmt"
"os"
"strconv"
@ -781,7 +780,7 @@ func TestACLReplication_TokensRedacted(t *testing.T) {
require.True(r, status.ReplicatedTokenIndex < token2.CreateIndex, "ReplicatedTokenIndex is not less than the token2s create index")
// ensures that token replication is erroring
require.True(r, status.LastError.After(minErrorTime), "Replication LastError not after the minErrorTime")
require.Equal(r, status.LastErrorMessage, errors.New("failed to retrieve unredacted tokens - replication token in use does not grant acl:write"))
require.Equal(r, status.LastErrorMessage, "failed to retrieve unredacted tokens - replication token in use does not grant acl:write")
})
}

View File

@ -1269,7 +1269,7 @@ type ACLReplicationStatus struct {
ReplicatedTokenIndex uint64
LastSuccess time.Time
LastError time.Time
LastErrorMessage error
LastErrorMessage string
}
// ACLTokenSetRequest is used for token creation and update operations