From 3b28ca4ce2a7b7933bea84ec184caca00e9fa925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C4=8Ctvrtka?= Date: Thu, 26 Oct 2023 17:55:21 +0200 Subject: [PATCH 1/2] PMM-12632 Fix agent client response. --- agent/client/cache/cache.go | 8 +++++--- agent/client/client.go | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/agent/client/cache/cache.go b/agent/client/cache/cache.go index 37ff100a48..47536b12da 100644 --- a/agent/client/cache/cache.go +++ b/agent/client/cache/cache.go @@ -16,6 +16,7 @@ package cache import ( + "fmt" "path" "github.com/pkg/errors" @@ -63,7 +64,7 @@ func New(cfg config.Cache) (*Cache, error) { // Send stores agent response to cache on nil channel. func (c *Cache) Send(resp *models.AgentResponse) error { var cache *bigqueue.Ring - switch resp.Payload.(type) { + switch t := resp.Payload.(type) { case *agentpb.StartActionResponse, *agentpb.StopActionResponse, *agentpb.PBMSwitchPITRResponse, @@ -73,14 +74,15 @@ func (c *Cache) Send(resp *models.AgentResponse) error { *agentpb.JobProgress, *agentpb.StopJobResponse, *agentpb.CheckConnectionResponse, - *agentpb.JobResult: + *agentpb.JobResult, + *agentpb.ServiceInfoResponse: cache = c.prioritized case *agentpb.AgentLogsResponse, *agentpb.Pong, *agentpb.SetStateResponse: cache = c.unprioritized default: - return nil + return fmt.Errorf("unsupported agent response type: %T", t) } return cache.Send(resp) } diff --git a/agent/client/client.go b/agent/client/client.go index 405724951d..f6ba5547a7 100644 --- a/agent/client/client.go +++ b/agent/client/client.go @@ -969,7 +969,10 @@ func (c *Client) sendAndWaitResponse(msg agentpb.AgentRequestPayload) (agentpb.S } func (c *Client) send(msg *models.AgentResponse) { - c.cache.Send(msg) //nolint:errcheck + err := c.cache.Send(msg) + if err != nil { + c.l.Error(err) + } } // check interface. From 3a800c90455cc3cdd51b141d9740f450b70d5e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C4=8Ctvrtka?= Date: Mon, 30 Oct 2023 08:39:16 +0100 Subject: [PATCH 2/2] PMM-12632 Required changes. --- agent/client/cache/cache.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/agent/client/cache/cache.go b/agent/client/cache/cache.go index 47536b12da..abd5805665 100644 --- a/agent/client/cache/cache.go +++ b/agent/client/cache/cache.go @@ -16,7 +16,6 @@ package cache import ( - "fmt" "path" "github.com/pkg/errors" @@ -64,7 +63,7 @@ func New(cfg config.Cache) (*Cache, error) { // Send stores agent response to cache on nil channel. func (c *Cache) Send(resp *models.AgentResponse) error { var cache *bigqueue.Ring - switch t := resp.Payload.(type) { + switch resp.Payload.(type) { case *agentpb.StartActionResponse, *agentpb.StopActionResponse, *agentpb.PBMSwitchPITRResponse, @@ -77,12 +76,8 @@ func (c *Cache) Send(resp *models.AgentResponse) error { *agentpb.JobResult, *agentpb.ServiceInfoResponse: cache = c.prioritized - case *agentpb.AgentLogsResponse, - *agentpb.Pong, - *agentpb.SetStateResponse: - cache = c.unprioritized default: - return fmt.Errorf("unsupported agent response type: %T", t) + cache = c.unprioritized } return cache.Send(resp) }