Skip to content

[Fleet] Mark agent as offline when last_checkin_status is disconnected#262334

Merged
michel-laterman merged 6 commits intoelastic:mainfrom
michel-laterman:fix/opamp-agent-disconnect
Apr 16, 2026
Merged

[Fleet] Mark agent as offline when last_checkin_status is disconnected#262334
michel-laterman merged 6 commits intoelastic:mainfrom
michel-laterman:fix/opamp-agent-disconnect

Conversation

@michel-laterman
Copy link
Copy Markdown
Contributor

@michel-laterman michel-laterman commented Apr 9, 2026

Summary

Adds a disconnected check to the agent status runtime field Painless script so that agents are marked offline immediately when fleet-server reports last_checkin_status: disconnected, rather than waiting for the time-based offline threshold.

Related fleet-server change: elastic/fleet-server#6792
Related issue: elastic/fleet-server#6784

@michel-laterman michel-laterman added bug Fixes for quality problems that affect the customer experience Team:Fleet Team label for Observability Data Collection Fleet team backport:version Backport to applied version labels v9.4.0 labels Apr 9, 2026
@michel-laterman michel-laterman marked this pull request as ready for review April 10, 2026 16:53
@michel-laterman michel-laterman requested a review from a team as a code owner April 10, 2026 16:53
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/fleet (Team:Fleet)

@michel-laterman michel-laterman added the release_note:skip Skip the PR/issue when compiling release notes label Apr 10, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 10, 2026

Approvability

Verdict: Needs human review

This PR changes runtime behavior by adding a new 'disconnected' status value and modifying agent status computation to mark disconnected agents as 'offline'. Since this affects how agents are classified in production and the author doesn't own any of the modified Fleet files (owned by @elastic/fleet), human review by the code owners is appropriate.

You can customize Macroscope's approvability policy. Learn more.

Copy link
Copy Markdown
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good, it would be good to add integration tests in fleet_api_integration to verify that the ES query works correctly with test agent documents. Claude can help generate it.

@michel-laterman michel-laterman requested review from a team as code owners April 13, 2026 16:26
@michel-laterman michel-laterman force-pushed the fix/opamp-agent-disconnect branch from e40c7c4 to 73a2954 Compare April 13, 2026 16:28
@michel-laterman michel-laterman removed request for a team April 13, 2026 16:30
Comment thread x-pack/platform/test/fleet_api_integration/apis/agents/status.ts
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 003b9d02-0683-4e9e-a9a9-e2a4524d4d7d

📥 Commits

Reviewing files that changed from the base of the PR and between d1ec64f and c763735.

📒 Files selected for processing (9)
  • oas_docs/output/kibana.serverless.yaml
  • oas_docs/output/kibana.yaml
  • x-pack/platform/plugins/shared/fleet/common/types/models/agent.ts
  • x-pack/platform/plugins/shared/fleet/server/services/agents/build_status_runtime_field.test.ts
  • x-pack/platform/plugins/shared/fleet/server/services/agents/build_status_runtime_field.ts
  • x-pack/platform/plugins/shared/fleet/server/types/rest_spec/agent.ts
  • x-pack/platform/plugins/shared/fleet/server/types/so_attributes.ts
  • x-pack/platform/test/fleet_api_integration/apis/agents/status.ts
  • x-pack/platform/test/fleet_api_integration/helpers.ts

📝 Walkthrough

Walkthrough

This change extends agent status handling throughout the Fleet system by introducing 'disconnected' as a new allowed value for agent check-in status fields. The 'disconnected' status is added to TypeScript type definitions (AgentBase, FleetServerAgent, AgentSOAttributes), OpenAPI schemas, REST response schemas, and runtime field logic. The runtime field processor now treats agents with 'disconnected' status as offline. Integration tests and test helpers were updated to validate the new status handling with test data and assertions.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


Comment @coderabbitai help to get the list of available commands and usage tips.

@michel-laterman
Copy link
Copy Markdown
Contributor Author

@elastic/ski-docs, can I please get a review?

@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 9.4

https://github.com/elastic/kibana/actions/runs/24526885341

@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

History

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
9.4

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v9.4.0 v9.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants