From abfc1e4840ac0bf2e82001cb251c1341d883a34e Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Thu, 23 Dec 2021 16:56:30 -0500 Subject: [PATCH] snapshot: return the error from replyFn The only function passed to SnapshotRPC today always returns a nil error, so there's no way to exercise this bug in practice. This change is being made for correctness so that it doesn't become a problem in the future, if we ever pass a different function to SnapshotRPC. --- agent/consul/client.go | 2 +- agent/consul/server.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/consul/client.go b/agent/consul/client.go index ac64d704ab..999f986634 100644 --- a/agent/consul/client.go +++ b/agent/consul/client.go @@ -347,7 +347,7 @@ func (c *Client) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io // Let the caller peek at the reply. if replyFn != nil { if err := replyFn(&reply); err != nil { - return nil + return err } } diff --git a/agent/consul/server.go b/agent/consul/server.go index 91082a7d6b..e076af7214 100644 --- a/agent/consul/server.go +++ b/agent/consul/server.go @@ -1347,7 +1347,7 @@ func (s *Server) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io // Let the caller peek at the reply. if replyFn != nil { if err := replyFn(&reply); err != nil { - return nil + return err } }