Skip to content

Commit

Permalink
Avoid reporting Unhealthy on fleet connectivity issues (#1152) (#1153)
Browse files Browse the repository at this point in the history
Avoid reporting `Unhealthy` on fleet connectivity issues (#1152)

(cherry picked from commit d811ef3)

Co-authored-by: Michal Pristas <[email protected]>
  • Loading branch information
mergify[bot] and michalpristas authored Sep 12, 2022
1 parent f6d3542 commit c9ca4e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 4 additions & 6 deletions internal/pkg/agent/application/gateway/fleet/fleet_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,13 @@ func (f *fleetGateway) doExecute() (*fleetapi.CheckinResponse, error) {
)

f.log.Error(err)
f.statusReporter.Update(state.Failed, err.Error(), nil)
return nil, err
}
if f.checkinFailCounter > 1 {
// Update status reporter for gateway to degraded when there are two consecutive failures.
// Note that this may not propagate to fleet-server as the agent is having issues checking in.
// It may also (falsely) report a degraded session for 30s if it is eventually successful.
// However this component will allow the agent to report fleet gateway degredation locally.
f.statusReporter.Update(state.Degraded, fmt.Sprintf("checkin failed: %v", err), nil)
// do not update status reporter with failure
// status reporter would report connection failure on first successful connection, leading to
// stale result for certain period causing slight confusion.
f.log.Errorf("checking number %d failed: %s", f.checkinFailCounter, err.Error())
}
continue
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
"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/fleetapi"
noopacker "github.com/elastic/elastic-agent/internal/pkg/fleetapi/acker/noop"
"github.com/elastic/elastic-agent/internal/pkg/scheduler"
Expand Down Expand Up @@ -705,7 +704,6 @@ func TestRetriesOnFailures(t *testing.T) {
queue.On("Actions").Return([]fleetapi.Action{})

fleetReporter := &testutils.MockReporter{}
fleetReporter.On("Update", state.Degraded, mock.Anything, mock.Anything).Times(2)
fleetReporter.On("Update", mock.Anything, mock.Anything, mock.Anything).Maybe()
fleetReporter.On("Unregister").Maybe()

Expand Down

0 comments on commit c9ca4e1

Please sign in to comment.