From 29fe423f4ce62588deb08d797a406b8efaaaa906 Mon Sep 17 00:00:00 2001 From: Julia Bardi Date: Thu, 29 Sep 2022 10:32:46 +0200 Subject: [PATCH 1/4] Added status message to CheckinRequest --- internal/pkg/agent/application/gateway/fleet/fleet_gateway.go | 1 + internal/pkg/fleetapi/checkin_cmd.go | 1 + 2 files changed, 2 insertions(+) diff --git a/internal/pkg/agent/application/gateway/fleet/fleet_gateway.go b/internal/pkg/agent/application/gateway/fleet/fleet_gateway.go index b88a0cafee0..897b81ea0d3 100644 --- a/internal/pkg/agent/application/gateway/fleet/fleet_gateway.go +++ b/internal/pkg/agent/application/gateway/fleet/fleet_gateway.go @@ -337,6 +337,7 @@ func (f *fleetGateway) execute(ctx context.Context) (*fleetapi.CheckinResponse, AckToken: ackToken, Metadata: ecsMeta, Status: f.statusController.StatusString(), + Message: f.statusController.Status().Message, } resp, err := cmd.Execute(ctx, req) diff --git a/internal/pkg/fleetapi/checkin_cmd.go b/internal/pkg/fleetapi/checkin_cmd.go index e225aababb9..6fad2ccca5d 100644 --- a/internal/pkg/fleetapi/checkin_cmd.go +++ b/internal/pkg/fleetapi/checkin_cmd.go @@ -23,6 +23,7 @@ const checkingPath = "/api/fleet/agents/%s/checkin" // CheckinRequest consists of multiple events reported to fleet ui. type CheckinRequest struct { Status string `json:"status"` + Message string `json:"message"` AckToken string `json:"ack_token,omitempty"` Metadata *info.ECSMeta `json:"local_metadata,omitempty"` } From 6766525ddc955abaf2372c1dc6b41c71f26617e0 Mon Sep 17 00:00:00 2001 From: Julia Bardi Date: Thu, 29 Sep 2022 10:51:22 +0200 Subject: [PATCH 2/4] added changelog --- CHANGELOG.next.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 7d500cf8f53..2ce614336a4 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -208,3 +208,4 @@ - Add `lumberjack` input type to the Filebeat spec. {pull}[959] - Add support for hints' based autodiscovery in kubernetes provider. {pull}[698] - Improve logging during upgrades. {pull}[1287] +- Added status message to CheckinRequest {pull}[1369] From 80ffdb7fa81a73d1ee8eba3c56c2d72628023811 Mon Sep 17 00:00:00 2001 From: Julia Bardi Date: Thu, 29 Sep 2022 11:09:19 +0200 Subject: [PATCH 3/4] updated test --- .../pkg/agent/application/gateway/fleet/fleet_gateway_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/pkg/agent/application/gateway/fleet/fleet_gateway_test.go b/internal/pkg/agent/application/gateway/fleet/fleet_gateway_test.go index 2d691185c1c..0cc00e739a8 100644 --- a/internal/pkg/agent/application/gateway/fleet/fleet_gateway_test.go +++ b/internal/pkg/agent/application/gateway/fleet/fleet_gateway_test.go @@ -26,6 +26,7 @@ import ( "github.com/elastic/elastic-agent/internal/pkg/agent/storage" "github.com/elastic/elastic-agent/internal/pkg/agent/storage/store" "github.com/elastic/elastic-agent/internal/pkg/core/state" + "github.com/elastic/elastic-agent/internal/pkg/core/status" "github.com/elastic/elastic-agent/internal/pkg/fleetapi" noopacker "github.com/elastic/elastic-agent/internal/pkg/fleetapi/acker/noop" "github.com/elastic/elastic-agent/internal/pkg/scheduler" @@ -717,6 +718,7 @@ func TestRetriesOnFailures(t *testing.T) { statusController.On("RegisterComponent", "gateway").Return(fleetReporter).Once() statusController.On("RegisterLocalComponent", "gateway-checkin").Return(localReporter).Once() statusController.On("StatusString").Return("string") + statusController.On("Status").Return(status.AgentStatus{Message: "message"}) gateway, err := newFleetGatewayWithScheduler( ctx, From fc8fc552be670d348861787ebbc49de1e6cb7ba4 Mon Sep 17 00:00:00 2001 From: Julia Bardi Date: Thu, 29 Sep 2022 13:48:59 +0200 Subject: [PATCH 4/4] added omitempty --- internal/pkg/fleetapi/checkin_cmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/pkg/fleetapi/checkin_cmd.go b/internal/pkg/fleetapi/checkin_cmd.go index 6fad2ccca5d..d6a63a45e29 100644 --- a/internal/pkg/fleetapi/checkin_cmd.go +++ b/internal/pkg/fleetapi/checkin_cmd.go @@ -23,7 +23,7 @@ const checkingPath = "/api/fleet/agents/%s/checkin" // CheckinRequest consists of multiple events reported to fleet ui. type CheckinRequest struct { Status string `json:"status"` - Message string `json:"message"` + Message string `json:"message,omitempty"` AckToken string `json:"ack_token,omitempty"` Metadata *info.ECSMeta `json:"local_metadata,omitempty"` }