Skip to content

Commit

Permalink
[Security Solution][Endpoint] Fix error when checking fleet-server st…
Browse files Browse the repository at this point in the history
…andalone is registered with ES (#170361)

## Summary

- Fixes an error in fleet-server standalone (serverless) CLI service
when query to ES returns "index not found" (expected if there are no
servers registered)
  • Loading branch information
paul-tavares authored Nov 2, 2023
1 parent 195ef3d commit 1a47e0f
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ const startFleetServerWithDocker = async ({
await updateFleetElasticsearchOutputHostNames(kbnClient, log);

if (isServerless) {
log.info(`Waiting for server to register with Elasticsearch`);
log.info(`Waiting for server [${hostname}] to register with Elasticsearch`);

await waitForFleetServerToRegisterWithElasticsearch(kbnClient, hostname, 120000);
} else {
Expand Down Expand Up @@ -684,7 +684,7 @@ const waitForFleetServerToRegisterWithElasticsearch = async (
.then((response) => response.data)
.catch(catchAxiosErrorFormatAndThrow);

return (fleetServerRecord.hits.total as estypes.SearchTotalHits).value === 1;
return ((fleetServerRecord?.hits?.total as estypes.SearchTotalHits)?.value ?? 0) === 1;
}, RETRYABLE_TRANSIENT_ERRORS);

if (!found) {
Expand Down

0 comments on commit 1a47e0f

Please sign in to comment.