Skip to content

Commit

Permalink
Fixes issue where context cancelling could result in an invalid error…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
mergify[bot] and blakerouse authored Sep 9, 2024
1 parent 30f22e3 commit 2541a5b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,13 @@ func (f *FleetGateway) doExecute(ctx context.Context, bo backoff.Backoff) (*flee
}

if !bo.Wait() {
// Something bad has happened and we log it and we should update our current state.
if ctx.Err() != nil {
// if the context is cancelled, break out of the loop
break
}

// This should not really happen, but just in-case this error is used to show that
// something strange occurred and we want to log it and report it.
err := errors.New(
"checkin retry loop was stopped",
errors.TypeNetwork,
Expand Down
5 changes: 0 additions & 5 deletions testing/integration/endpoint_security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,6 @@ func testInstallAndUnenrollWithEndpointSecurity(t *testing.T, info *define.Info,
return false
}

if state.FleetState != client.Failed {
t.Logf("Fleet state has not been marked as failed yet!\n%+v", state)
return false
}

return true
},
endpointHealthPollingTimeout,
Expand Down
2 changes: 0 additions & 2 deletions testing/integration/linux_rpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ func TestRpmLogIngestFleetManaged(t *testing.T) {
Sudo: true,
})

t.Skip("Flaky https://github.com/elastic/elastic-agent/issues/5311")

ctx, cancel := testcontext.WithDeadline(t, context.Background(), time.Now().Add(10*time.Minute))
defer cancel()

Expand Down

0 comments on commit 2541a5b

Please sign in to comment.