fix(status): handle Serverless Elasticsearch in elastic status - #398
Conversation
Serverless projects remove cluster-level APIs, so `GET /_cluster/health` returns 410 Gone. The status probe surfaced this as `request failed (410)` and marked Elasticsearch as down, even though the project was healthy. On a 410 from `_cluster/health`, fall back to `GET /` (served on Serverless) and report the build version. Stateful clusters keep their single-request path and existing `green (3 nodes)` output unchanged. EsCheckOk is now a discriminated union (stateful | serverless); the formatter renders Serverless as `serverless (<version>)`.
✅MegaLinter analysis: Success
Notices📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining See detailed reports in MegaLinter artifacts MegaLinter is graciously provided by OX Security |
| ): Promise<EsCheck> { | ||
| const result = await pingService(block.url, '/_cluster/health', block.auth, fetchFn) | ||
| if (!result.ok) return { ok: false, url: block.url, error: result.error } | ||
| if (!result.ok) { |
There was a problem hiding this comment.
My only suggestion: if we have any hints that a cluster might be serverless (its hostname, perhaps, or if the commandProfile is set to serverless), we should run the serverless check first to reduce the chances of sending a request that's doomed to fail.
|
@JoshMock I reproduced this today with CLI 0.4.0 against a live Serverless project using an Elastic Cloud API key with Elasticsearch access. At the same time, This is especially noticeable during onboarding: a user can configure Serverless correctly and the first status check tells them the request failed. It gives a poor first impression and strongly suggests that their configuration or credentials are broken. Since the fix is already approved, could we get it merged and included in the next release? |
|
❌ Author of the following commits did not sign a Contributor Agreement: Please, read and sign the above mentioned agreement if you want to contribute to this project |
|
CLA check is failing because Matt authored this PR but no longer works at Elastic. 💔 I'm just finishing his work and merging. |
Problem
elastic statusreports Elasticsearch as down on Serverless projects, even when the project is healthy:Root cause
The Elasticsearch probe calls
GET /_cluster/health(src/status/checks.ts). Serverless removes cluster-level APIs and answers that endpoint with 410 Gone, which the generic HTTP classifier turned intorequest failed (410). Kibana's/api/statusexists on Serverless, so it already showed✓.Confirmed against a live Serverless project:
GET /version.number,build_flavor: serverless)GET /_cluster/healthGET /_security/_authenticateFix
pingServicenow surfaces the HTTP status code on failure.checkElasticsearchkeeps the single/_cluster/healthrequest for stateful clusters. On a 410 specifically, it falls back toGET /(served on Serverless) and readsversion.number.EsCheckOkbecomes a discriminated union:EsCheckStateful { flavor, status, nodes }|EsCheckServerless { flavor, version }.serverless (<version>); stateful output is unchanged.Only a 410 triggers the fallback. Other failures (401, 503, network) are still reported as failures, and stateful clusters are completely unaffected.
Result
Exit code is now
0.Test plan
tsc -bcleantest/status/*.test.ts)version.number→unexpected response, root failure propagation (401), serverless rendering