Repository: RasaHQ/rasa

Issue:
Include agent readiness check in /status resource
**Description of Problem**:
In older versions of RASA, the `/status` resource contained a check for whether the system is ready to receive traffic.
This check was used as a k8s readiness probe which became useless in 1.0.x.

**Overview of the Solution**:
Add the `@ensure_loaded_agent` on the `/status` resource so that it returns a 409 in the case that the agent is not initialized.

**Definition of Done**:
- [x] The `/status` resource returns `409` when the agent is not ready to evaluate user requests
- [x] Tests are added
- [x] Feature is documented (API)


Discussion:

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index fe19f4fbee6..f7e31ce1754 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -11,6 +11,7 @@ This project adheres to `Semantic Versioning`_ starting with version 1.0.
 
 Added
 -----
+- added agent readiness check to the ``/status`` resource
 
 Changed
 -------
diff --git a/docs/_static/spec/rasa.yml b/docs/_static/spec/rasa.yml
index e8d673b0cd5..ff05ba34759 100644
--- a/docs/_static/spec/rasa.yml
+++ b/docs/_static/spec/rasa.yml
@@ -99,6 +99,8 @@ paths:
           $ref: '#/components/responses/401NotAuthenticated'
         403:
           $ref: '#/components/responses/403NotAuthorized'
+        409:
+          $ref: '#/components/responses/409Conflict'
 
 
   /conversations/{conversation_id}/tracker:
diff --git a/rasa/server.py b/rasa/server.py
index d5043743643..33dc3a99e83 100644
--- a/rasa/server.py
+++ b/rasa/server.py
@@ -329,6 +329,7 @@ def create_app(
 
     @app.get("/status")
     @requires_auth(app, auth_token)
+    @ensure_loaded_agent(app)
     async def status(request: Request):
         """Respond with the model name and the fingerprint of that model."""
 


Test patch:
diff --git a/tests/test_server.py b/tests/test_server.py
index c0fc945bda3..02a7d83aa46 100644
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -90,6 +90,11 @@ def test_status_secured(rasa_secured_app):
     assert response.status == 401
 
 
+def test_status_not_ready_agent(rasa_app_nlu):
+    _, response = rasa_app_nlu.get("/status")
+    assert response.status == 409
+
+
 @pytest.mark.parametrize(
     "response_test",
     [
@@ -612,8 +617,7 @@ def test_unload_model_error(rasa_app):
     assert response.status == 204
 
     _, response = rasa_app.get("/status")
-    assert response.status == 200
-    assert "model_file" in response.json and response.json["model_file"] is None
+    assert response.status == 409
 
 
 def test_get_domain(rasa_app):