Skip to content

[Platform] Status endpoint incorrectly returns 200 before Kibana is ready #66326

@sorenlouv

Description

@sorenlouv

I'm trying to programatically determine when Kibana is ready to serve requests and therefore calling the status api /api/status.

Expected behaviour
Until Kibana is up and ready to receive requests I would expect /api/status to return something other than 200.

Actual behaviour
/api/status initially returns 503

At some point the optimization step is complete which will be logged as:

[info][optimize] Optimization success in 2.83 seconds

At this point /api/status will return 200. However opening Kibana in the browser will still return an error message: "Elastic did not load properly. Check the server output for more information."

image

After about 60 seconds Kibana will output:

[success][@kbn/optimizer] 88 bundles compiled successfully after 297.9 sec, watching for changes

Kibana will now be truly ready to serve requests

Reproduce
This only seems to happen in a bare repository without any cached artefacts - at all! The easiest way to get to this state is by wiping all build files find {x-pack,src} -type d -name "target" | xargs rm -rf .

Cold start Kibana:

find {x-pack,src} -type d -name "target" | xargs rm -rf  && yarn kbn bootstrap &&   node ./scripts/kibana --no-base-path --dev --elasticsearch.username admin --elasticsearch.password changeme --elasticsearch.hosts http://localhost:9200

Poll the status endpoint while Kibana is starting:

for run in {1..1000}; do curl -s -o /dev/null -w "%{http_code}\n" -u admin:changeme localhost:5601/api/status; sleep 0.5; done

Note: you should be able to remove the credentials if you are connecting to an ES without security enabled

Metadata

Metadata

Assignees

No one assigned

    Labels

    Team:CorePlatform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t//

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions