Issues API: Enable GET /issues endpoint (#4118)

* enable `GET /issues` endpoint

* add access test
This commit is contained in:
Luis Cossío
2024-04-26 08:08:18 -04:00
committed by generall
parent 12964abe3c
commit 8a986ea4fd
6 changed files with 63 additions and 6 deletions

View File

@@ -522,6 +522,31 @@
}
}
},
"/issues": {
"get": {
"summary": "Get issues",
"description": "Get a report of performance issues and configuration suggestions",
"operationId": "get_issues",
"tags": [
"beta"
],
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
},
"4XX": {
"description": "error"
}
}
}
},
"/cluster": {
"get": {
"tags": [

View File

@@ -137,3 +137,19 @@ paths:
"4XX":
description: error
/issues:
get:
summary: Get issues
description: Get a report of performance issues and configuration suggestions
operationId: get_issues
tags:
- beta
responses:
"200":
description: Successful response
content:
application/json:
schema:
type: object
"4XX":
description: error

View File

@@ -1,14 +1,23 @@
use actix_web::rt::time::Instant;
use actix_web::{get, Responder};
use actix_web::{get, web, Responder};
use collection::operations::types::IssuesReport;
use storage::rbac::AccessRequirements;
use crate::actix::auth::ActixAccess;
use crate::actix::helpers::process_response;
#[get("/issues")]
async fn get_collections() -> impl Responder {
async fn get_issues(ActixAccess(access): ActixAccess) -> impl Responder {
let timing = Instant::now();
let response = Ok(IssuesReport {
issues: issues::all_issues(),
});
let response = access
.check_global_access(AccessRequirements::new().manage())
.map(|_| IssuesReport {
issues: issues::all_issues(),
});
process_response(response, timing)
}
// Configure services
pub fn config_issues_api(cfg: &mut web::ServiceConfig) {
cfg.service(get_issues);
}

View File

@@ -25,6 +25,7 @@ use crate::actix::api::cluster_api::config_cluster_api;
use crate::actix::api::collections_api::config_collections_api;
use crate::actix::api::count_api::count_points;
use crate::actix::api::discovery_api::config_discovery_api;
use crate::actix::api::issues_api::config_issues_api;
use crate::actix::api::recommend_api::config_recommend_api;
use crate::actix::api::retrieve_api::{get_point, get_points, scroll_points};
use crate::actix::api::search_api::config_search_api;
@@ -161,6 +162,7 @@ pub fn init(
.configure(config_recommend_api)
.configure(config_discovery_api)
.configure(config_shards_api)
.configure(config_issues_api)
// Ordering of services is important for correct path pattern matching
// See: <https://github.com/qdrant/qdrant/issues/3543>
.service(scroll_points)

View File

@@ -533,6 +533,7 @@ ACTION_ACCESS = {
"metrics": EndpointAccess(True, False, True, "GET /metrics", coll_r=False),
"post_locks": EndpointAccess(False, False, True, "POST /locks"),
"get_locks": EndpointAccess(True, False, True, "GET /locks", coll_r=False),
"get_issues": EndpointAccess(False, False, True, "GET /issues"),
}
@@ -1734,3 +1735,7 @@ def test_post_locks():
def test_get_locks():
check_access("get_locks")
def test_get_issues():
check_access("get_issues")

View File

@@ -36,7 +36,7 @@ fi
rm -f ./docs/redoc/master/.diff.openapi.json
NUMBER_OF_APIS=$(cat ./docs/redoc/master/openapi.json | jq '.paths | length')
EXPECTED_NUMBER_OF_APIS=50
EXPECTED_NUMBER_OF_APIS=51
if [ "$NUMBER_OF_APIS" -ne "$EXPECTED_NUMBER_OF_APIS" ]; then
echo "ERROR: It looks like the total number of APIs has changed."