Skip to content

Commit 2541a5b

Browse files
Fixes issue where context cancelling could result in an invalid error being reported (#5329) (#5482)
* Fix issue. * Update internal/pkg/agent/application/gateway/fleet/fleet_gateway.go Co-authored-by: Paolo Chilà <paolo.chila@elastic.co> * Remove check for failed as it no-longer gets marked failed. --------- Co-authored-by: Paolo Chilà <paolo.chila@elastic.co> Co-authored-by: Pierre HILBERT <pierre.hilbert@elastic.co> Co-authored-by: Julien Lind <julien.lind@elastic.co> Co-authored-by: Shaunak Kashyap <ycombinator@gmail.com> (cherry picked from commit 96e02e0) Co-authored-by: Blake Rouse <blake.rouse@elastic.co>
1 parent 30f22e3 commit 2541a5b

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

internal/pkg/agent/application/gateway/fleet/fleet_gateway.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,13 @@ func (f *FleetGateway) doExecute(ctx context.Context, bo backoff.Backoff) (*flee
198198
}
199199

200200
if !bo.Wait() {
201-
// Something bad has happened and we log it and we should update our current state.
201+
if ctx.Err() != nil {
202+
// if the context is cancelled, break out of the loop
203+
break
204+
}
205+
206+
// This should not really happen, but just in-case this error is used to show that
207+
// something strange occurred and we want to log it and report it.
202208
err := errors.New(
203209
"checkin retry loop was stopped",
204210
errors.TypeNetwork,

testing/integration/endpoint_security_test.go

-5
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,6 @@ func testInstallAndUnenrollWithEndpointSecurity(t *testing.T, info *define.Info,
275275
return false
276276
}
277277

278-
if state.FleetState != client.Failed {
279-
t.Logf("Fleet state has not been marked as failed yet!\n%+v", state)
280-
return false
281-
}
282-
283278
return true
284279
},
285280
endpointHealthPollingTimeout,

testing/integration/linux_rpm_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ func TestRpmLogIngestFleetManaged(t *testing.T) {
4444
Sudo: true,
4545
})
4646

47-
t.Skip("Flaky https://github.com/elastic/elastic-agent/issues/5311")
48-
4947
ctx, cancel := testcontext.WithDeadline(t, context.Background(), time.Now().Add(10*time.Minute))
5048
defer cancel()
5149

0 commit comments

Comments
 (0)