Archived
front: a refused request does not wake a model to be refused
Every forwarded request leased its model, and the lease fired demand for a cold or parked one before any handler ran. On the guarded routes -- the lora admin, /diagnostics, /reset_prefix_cache, DELETE /sessions, the control vector -- the handler then answered 403 keyless: the wake had already asked the scheduler for a real load, which can fetch the repository and evict residents to make room. Loop one cheap GET over an enumerated model name and the fleet churns for an audience that never gets an answer. The front already knows reads that report on a model are no reason to bring one back; the same courtesy is now owed to a request the guard will refuse. The fleet hands the front its operator rule -- the very predicate its admin guard reads -- and a guarded route from anyone else reads the not-open state and stops. Open models still dispatch, keyed boxes still wake everything, and the operator keeps the diagnostics that bring a parked model forward.
This commit is contained in:
1 parent
41a1aa00fe
commit
b83d53cf19
4 files changed
+114
-8
No files matched your search
@@ -52,6 +52,12 @@ TEST(the_dashboards_reads_do_not_count_as_wanting_a_model) {
|
||||
q.path = path;
|
||||
q.method = "GET";
|
||||
CHECK(Front::dashboard_read(q));
|
||||
/* The router dispatches a doubled or trailing slash to the same route; so must the
|
||||
* read's exemption, or the read wakes a model for a slash. */
|
||||
q.path = std::string("/") + path;
|
||||
CHECK(Front::dashboard_read(q));
|
||||
q.path = std::string(path) + "/";
|
||||
CHECK(Front::dashboard_read(q));
|
||||
}
|
||||
q.path = "/admin/control-vector";
|
||||
q.method = "POST";
|
||||
@@ -63,6 +69,36 @@ TEST(the_dashboards_reads_do_not_count_as_wanting_a_model) {
|
||||
CHECK(!Front::dashboard_read(q));
|
||||
}
|
||||
|
||||
/* The set that must not wake a model for a caller its handler will refuse: exactly the routes
|
||||
* Server::register_routes guards with local_operator keyless, and nothing beside them. */
|
||||
TEST(guarded_routes_are_the_local_operator_ones) {
|
||||
HttpRequest q;
|
||||
q.method = "GET"; q.path = "/diagnostics"; CHECK(Front::guarded_route(q));
|
||||
/* The router collapses "//x" and "x/" into "/x" (split_path, http.cpp) -- the guard sees
|
||||
* the same path the handler reaches, or a slash buys the wake the guard denies. */
|
||||
q.path = "//diagnostics"; CHECK(Front::guarded_route(q));
|
||||
q.path = "/diagnostics/"; CHECK(Front::guarded_route(q));
|
||||
q.method = "POST"; q.path = "/reset_prefix_cache"; CHECK(Front::guarded_route(q));
|
||||
q.path = "/admin/control-vector"; CHECK(Front::guarded_route(q));
|
||||
q.method = "GET"; q.path = "/admin/control-vector"; CHECK(Front::guarded_route(q));
|
||||
q.method = "DELETE"; q.path = "/sessions"; CHECK(Front::guarded_route(q));
|
||||
/* The :label form is registered and guarded next to it (server.cpp); the front must not
|
||||
* wake a model for a stranger's DELETE /sessions/whatever either. */
|
||||
q.path = "/sessions/abc"; CHECK(Front::guarded_route(q));
|
||||
q.method = "POST"; q.path = "/v1/load_lora_adapter"; CHECK(Front::guarded_route(q));
|
||||
q.path = "/v1/unload_lora_adapter"; CHECK(Front::guarded_route(q));
|
||||
/* The rest is unguarded: the open dashboard reads stay as they are, and inference keeps
|
||||
* waking its model for whoever asks -- that is what a keyless box is for. */
|
||||
q.method = "GET"; q.path = "/sessions"; CHECK(!Front::guarded_route(q));
|
||||
q.path = "/stats"; CHECK(!Front::guarded_route(q));
|
||||
q.method = "POST"; q.path = "/v1/chat/completions"; CHECK(!Front::guarded_route(q));
|
||||
q.method = "GET"; q.path = "/v1/models"; CHECK(!Front::guarded_route(q));
|
||||
/* Shapes the :label pattern cannot match are no route at all, so they wake nothing -- but a
|
||||
* trailing slash is not such a shape: the router collapses it to the guarded bare route. */
|
||||
q.method = "DELETE"; q.path = "/sessions/"; CHECK(Front::guarded_route(q));
|
||||
q.path = "/sessions/a/b"; CHECK(!Front::guarded_route(q));
|
||||
}
|
||||
|
||||
TEST(a_finished_job_is_answered_by_its_id_with_no_model) {
|
||||
Front f(TransportOptions{}, 0);
|
||||
const int64_t later = (int64_t)std::time(nullptr) + 100;
|
||||
|
||||
Reference in new issue
Block a user