Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve some basic config info at /info. #14842

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions api/doc/spec.json
Original file line number Diff line number Diff line change
@@ -1900,6 +1900,28 @@
"operationId": "spec"
}
},
"/info": {
"get": {
"tags": [
"General"
],
"summary": "Show some basic info of the node.",
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {}
}
}
}
}
},
"operationId": "info"
}
},
"/-/healthy": {
"get": {
"tags": [
14 changes: 14 additions & 0 deletions api/doc/spec.yaml
Original file line number Diff line number Diff line change
@@ -1416,6 +1416,20 @@ paths:
schema:
type: string
operationId: spec
/info:
get:
tags:
- General
summary: Show some basic info of the node.
responses:
'200':
description: ''
content:
application/json:
schema:
type: object
additionalProperties: {}
operationId: info
/-/healthy:
get:
tags:
57 changes: 56 additions & 1 deletion api/src/basic.rs
Original file line number Diff line number Diff line change
@@ -10,9 +10,14 @@ use crate::{
};
use anyhow::Context as AnyhowContext;
use aptos_api_types::AptosErrorCode;
use poem_openapi::{param::Query, payload::Html, Object, OpenApi};
use poem_openapi::{
param::Query,
payload::{Html, Json},
Object, OpenApi,
};
use serde::{Deserialize, Serialize};
use std::{
collections::HashMap,
ops::Sub,
sync::Arc,
time::{Duration, SystemTime, UNIX_EPOCH},
@@ -60,6 +65,56 @@ impl BasicApi {
Html(OPEN_API_HTML.to_string())
}

/// Show some basic info of the node.
#[oai(
path = "/info",
method = "get",
operation_id = "info",
tag = "ApiTags::General"
)]
async fn info(&self) -> Json<HashMap<String, serde_json::Value>> {
let mut info = HashMap::new();
info.insert(
"bootstrapping_mode".to_string(),
serde_json::to_value(
self.context
.node_config
.state_sync
.state_sync_driver
.bootstrapping_mode,
)
.unwrap(),
);
info.insert(
"continuous_syncing_mode".to_string(),
serde_json::to_value(
self.context
.node_config
.state_sync
.state_sync_driver
.continuous_syncing_mode,
)
.unwrap(),
);
info.insert(
"new_storage_format".to_string(),
serde_json::to_value(
self.context
.node_config
.storage
.rocksdb_configs
.enable_storage_sharding,
)
.unwrap(),
);
info.insert(
"internal_indexer_config".to_string(),
serde_json::to_value(&self.context.node_config.indexer_db_config).unwrap(),
);

Json(info)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this is intended only for human consumption, hence the keys like "Internal Indexer Config" rather than internal_indexer_config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's what I'm expecting. Changed to snake_case anyway.

}

/// Check basic node health
///
/// By default this endpoint just checks that it can get the latest ledger