From 814ef6b103cf9e89f41df35928025c091aaee3ac Mon Sep 17 00:00:00 2001 From: Giulio Micheloni Date: Thu, 15 Jul 2021 11:31:44 +0200 Subject: [PATCH] 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 --- agent/consul/acl_replication.go | 2 +- agent/consul/acl_replication_test.go | 3 +-- agent/structs/acl.go | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/agent/consul/acl_replication.go b/agent/consul/acl_replication.go index f76900356c..6c5d07f311 100644 --- a/agent/consul/acl_replication.go +++ b/agent/consul/acl_replication.go @@ -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) { diff --git a/agent/consul/acl_replication_test.go b/agent/consul/acl_replication_test.go index 841d18020a..0bb96a8457 100644 --- a/agent/consul/acl_replication_test.go +++ b/agent/consul/acl_replication_test.go @@ -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") }) } diff --git a/agent/structs/acl.go b/agent/structs/acl.go index 1a93f88421..f8029f1a73 100644 --- a/agent/structs/acl.go +++ b/agent/structs/acl.go @@ -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