Skip to content

[9.5](backport #7548) fix: handle index_not_found in token resolver to avoid spurious checkin errors - #7559

Merged
ycombinator merged 2 commits into
9.5from
mergify/bp/9.5/pr-7548
Aug 5, 2026
Merged

[9.5](backport #7548) fix: handle index_not_found in token resolver to avoid spurious checkin errors#7559
ycombinator merged 2 commits into
9.5from
mergify/bp/9.5/pr-7548

Conversation

@mergify

@mergify mergify Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What is the problem this PR solves?

When .fleet-actions does not yet exist (e.g. a new project that has never had an explicit agent action), a fleet-server restart or a new fleet-server instance being spun up clears the in-memory LRU ack-token cache. The subsequent cache-miss triggers a search on .fleet-actions via TokenResolver.Resolvedl.FindSeqNoByDocID. ErrIndexNotFound was not handled in this code path and propagated all the way up to the agent check-in handler, logging resolveSeqNo: elastic fail 404: index_not_found_exception: no such index [.fleet-actions] on every check-in.

How does this PR solve the problem?

Treats ErrIndexNotFound the same as ErrNotFound in TokenResolver.Resolve, so the caller (resolveSeqNo in handleCheckin.go) falls back to agent.ActionSeqNo gracefully. This is consistent with how every other read path in fleet-server already handles a missing .fleet-actions index (e.g. findActionsHits, DeleteExpiredForIndex).

How to test this PR locally

Start fleet-server against a cluster where .fleet-actions does not exist, enroll an agent, and verify check-ins succeed without resolveSeqNo errors in the logs.

Design Checklist

  • I have ensured my design is stateless and will work when multiple fleet-server instances are behind a load balancer.
  • I have or intend to scale test my changes, ensuring it will work reliably with 100K+ agents connected.
  • I have included fail safe mechanisms to limit the load on fleet-server: rate limiting, circuit breakers, caching, load shedding, etc.

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool

🤖 Generated with Claude Code


This is an automatic backport of pull request #7548 done by Mergify.

…in errors (#7548)

* fix: handle index_not_found in token resolver to avoid spurious checkin errors

When .fleet-actions does not yet exist (new project with no agent actions)
or has been deleted, a fleet-server restart clears the LRU ack-token cache.
The subsequent cache-miss search on .fleet-actions returned an unhandled
index_not_found_exception that propagated as an error to the agent check-in,
logging "resolveSeqNo: elastic fail 404". Treat ErrIndexNotFound the same as
ErrNotFound so the caller falls back to agent.ActionSeqNo gracefully.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: add changelog fragment for token resolver index-not-found fix

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit 12b3ede)
@mergify mergify Bot added the backport label Aug 5, 2026
@mergify
mergify Bot requested a review from a team as a code owner August 5, 2026 12:35
@mergify
mergify Bot requested review from lorienhu and samuelvl August 5, 2026 12:35
@github-actions github-actions Bot added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Aug 5, 2026
@ycombinator
ycombinator enabled auto-merge (squash) August 5, 2026 12:43
ycombinator
ycombinator previously approved these changes Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

TL;DR

The failing Buildkite step (Run unit tests: MacOS 13) exited with go test ... ./... status 1, but the provided log excerpt is truncated and does not include the actual failing package/test output. From this branch/commit, the changed code in this PR passes race-enabled tests, so this currently looks like a non-code or transient CI failure until full failing lines are available.

Remediation

  • Retry the failed Buildkite step once to rule out a transient MacOS runner failure.
  • If it fails again, capture and attach the full step log (including the first failing --- FAIL: or FAIL\t<package> line) and re-run go test -tags=grpcnotrace -v -race -coverprofile=build/coverage-darwin.out ./... on MacOS for the exact failing package.
Investigation details

Root Cause

The pre-fetched log at /tmp/gh-aw/buildkite-logs/fleet-server-smartbear-testexecute-run-unit-tests-macos-13.txt only contains trailing output and ends with a generic harness failure:

  • FAIL
  • Error: running "go test -tags=grpcnotrace -v -race -coverprofile=build/coverage-darwin.out ./..." failed with exit code 1

It does not include the specific failing test/package line, so a concrete code-level root cause cannot be proven from the available Buildkite evidence.

I also checked the PR delta (backport of #7548):

  • internal/pkg/action/token_resolver.go (new ErrIndexNotFound handling in Resolve, around the newly added branch near line 51 in diff)
  • internal/pkg/action/token_resolver_test.go (new tests)

These changes are narrow and local to token resolution behavior, and do not overlap with any visible failing output in the provided CI excerpt.

Evidence

Verification

  • Re-ran PR-local race tests for changed area: go test -tags=grpcnotrace -race ./internal/pkg/action -run TestTokenResolverResolve -v (passes).
  • Re-ran repo-wide race tests in this environment: go test -tags=grpcnotrace -race ./... (passes).

Follow-up

  • No matching open flaky-test issue was found in elastic/fleet-server for this MacOS unit-test step signature. If the retry fails with the same concrete test/package, opening a flaky-test issue with the exact failing line would help tracking.

What is this? | From workflow: PR Buildkite Detective

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

The backport target branches have an older MockBulk.Search that uses a
bare type assertion (args.Get(0).(*es.ResultT)), which panics when nil
is passed. Return an empty &es.ResultT{} instead so the mock handles
both the IndexNotFound and OtherError test cases without panicking.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ycombinator
ycombinator merged commit 25d5314 into 9.5 Aug 5, 2026
12 checks passed
@ycombinator
ycombinator deleted the mergify/bp/9.5/pr-7548 branch August 5, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant