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

4 Node list page (Backend) #19

Open
wants to merge 27 commits into
base: 3-home-page
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Bob Management GUI changelog
- Logger Initialization (#14)
- Login Page, backend (#16)
- Home page, backend (#18)
- Node list page, backend (#19)
247 changes: 245 additions & 2 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,31 @@ paths:
description: Unauthorized
security:
- api_key: []
/api/v1/nodes/list:
get:
tags:
- services::api
summary: Returns simple list of all known nodes
description: |-
Returns simple list of all known nodes

# Errors

This function will return an error if a call to the primary node will fail
operationId: get_nodes_list
responses:
'200':
description: Simple Node List
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/dto.Node'
'401':
description: Unauthorized
security:
- api_key: []
/api/v1/nodes/rps:
get:
tags:
Expand Down Expand Up @@ -139,6 +164,82 @@ paths:
description: Unauthorized
security:
- api_key: []
/api/v1/nodes/{node_name}:
get:
tags:
- services::api
summary: Returns node inforamtion by their node name
description: |-
Returns node inforamtion by their node name

# Errors

This function will return an error if a call to the specified node will fail or node with
specified name not found
operationId: get_node_info
responses:
'200':
description: Node Inforamtion
content:
application/json:
schema:
$ref: '#/components/schemas/Node'
'401':
description: Unauthorized
'404':
description: Node not found
security:
- api_key: []
/api/v1/nodes/{node_name}/configuration:
get:
tags:
- services::api
summary: Get Configuration from Node
description: |-
Get Configuration from Node

# Errors

This function will return an error if the server was unable to get node'a client or the request to get configuration fails
operationId: raw_configuration_by_node
responses:
'200':
description: Node's configuration
content:
application/json:
schema:
$ref: '#/components/schemas/NodeConfiguration'
'401':
description: Unauthorized
'404':
description: Node Not Found
security:
- api_key: []
/api/v1/nodes/{node_name}/metrics:
get:
tags:
- services::api
summary: Get Raw Metrics from Node
description: |-
Get Raw Metrics from Node

# Errors

This function will return an error if the server was unable to get node'a client or the request to get metrics fails
operationId: raw_metrics_by_node
responses:
'200':
description: Node's metrics
content:
application/json:
schema:
$ref: '#/components/schemas/TypedMetrics'
'401':
description: Unauthorized
'404':
description: Node Not Found
security:
- api_key: []
components:
schemas:
BobConnectionData:
Expand Down Expand Up @@ -174,6 +275,36 @@ components:
example:
login: archeoss
password: '12345'
Disk:
allOf:
- $ref: '#/components/schemas/DiskStatus'
- type: object
required:
- name
- path
- totalSpace
- usedSpace
- iops
properties:
iops:
type: integer
format: int64
minimum: 0
name:
type: string
description: Disk name
path:
type: string
description: Disk path
totalSpace:
type: integer
format: int64
minimum: 0
usedSpace:
type: integer
format: int64
minimum: 0
description: Physical disk definition
DiskCount:
type: object
description: Disk count by their status
Expand Down Expand Up @@ -273,6 +404,41 @@ components:
type: object
additionalProperties:
$ref: '#/components/schemas/MetricsEntryModel'
Node:
allOf:
- $ref: '#/components/schemas/NodeStatus'
- type: object
required:
- name
- hostname
- vdisks
properties:
alienCount:
type: integer
format: int64
nullable: true
minimum: 0
corruptedCount:
type: integer
format: int64
nullable: true
minimum: 0
hostname:
type: string
name:
type: string
rps:
allOf:
- $ref: '#/components/schemas/RPS'
nullable: true
space:
allOf:
- $ref: '#/components/schemas/SpaceInfo'
nullable: true
vdisks:
type: array
items:
$ref: '#/components/schemas/VDisk'
NodeConfiguration:
type: object
properties:
Expand Down Expand Up @@ -419,6 +585,22 @@ components:
- hardware.free_space
- hardware.total_space
- hardware.descr_amount
Replica:
allOf:
- $ref: '#/components/schemas/ReplicaStatus'
- type: object
required:
- node
- disk
- path
properties:
disk:
type: string
node:
type: string
path:
type: string
description: '[`VDisk`]''s replicas'
ReplicaProblem:
type: string
description: Reasons why Replica is offline
Expand Down Expand Up @@ -797,6 +979,28 @@ components:
pearl.put_count_rate:
timestamp: 0
value: 0
VDisk:
allOf:
- $ref: '#/components/schemas/VDiskStatus'
- type: object
required:
- id
- partitionCount
- replicas
properties:
id:
type: integer
format: int64
minimum: 0
partitionCount:
type: integer
format: int64
minimum: 0
replicas:
type: array
items:
$ref: '#/components/schemas/Replica'
description: Virtual disk Component
VDiskStatus:
oneOf:
- type: object
Expand Down Expand Up @@ -828,8 +1032,47 @@ components:

Variants - Virtual Disk status
status == 'bad' when at least one of its replicas has problems
example:
status: good
dto.Node:
type: object
required:
- name
- address
properties:
address:
type: string
name:
type: string
vdisks:
type: array
items:
$ref: '#/components/schemas/dto.VDisk'
nullable: true
dto.Replica:
type: object
required:
- node
- disk
- path
properties:
disk:
type: string
node:
type: string
path:
type: string
dto.VDisk:
type: object
required:
- id
properties:
id:
type: integer
format: int32
replicas:
type: array
items:
$ref: '#/components/schemas/dto.Replica'
nullable: true
securitySchemes:
api_key:
type: apiKey
Expand Down
8 changes: 8 additions & 0 deletions backend/src/connector/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ impl Ord for MetricsEntryModel {
impl Eq for MetricsEntryModel {}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
#[cfg_attr(all(feature = "swagger", debug_assertions), schema(as = dto::Node))]
pub struct Node {
#[serde(rename = "name")]
pub name: String,
Expand All @@ -418,6 +420,7 @@ pub struct Node {

#[serde(rename = "vdisks")]
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(all(feature = "swagger", debug_assertions), schema(value_type = Option<Vec<dto::VDisk>>))]
pub vdisks: Option<Vec<VDisk>>,
}

Expand Down Expand Up @@ -697,6 +700,8 @@ impl std::str::FromStr for Partition {

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
#[cfg_attr(all(feature = "swagger", debug_assertions), schema(as = dto::Replica))]
pub struct Replica {
#[serde(rename = "node")]
pub node: String,
Expand Down Expand Up @@ -896,12 +901,15 @@ impl std::str::FromStr for StatusExt {

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
#[cfg_attr(all(feature = "swagger", debug_assertions), schema(as = dto::VDisk))]
pub struct VDisk {
#[serde(rename = "id")]
pub id: i32,

#[serde(rename = "replicas")]
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(all(feature = "swagger", debug_assertions), schema(value_type = Option<Vec<dto::Replica>>))]
pub replicas: Option<Vec<Replica>>,
}

Expand Down
12 changes: 7 additions & 5 deletions backend/src/connector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
headers::{authorization::Credentials, Authorization, HeaderMapExt},
http::{HeaderName, HeaderValue},
};
pub use futures::StreamExt;
pub use hyper::{service::Service, Response, Uri};
pub use futures::{Stream, StreamExt};
pub use hyper::{body::Bytes, service::Service, Response, Uri};

Check warning on line 14 in backend/src/connector/mod.rs

View workflow job for this annotation

GitHub Actions / gen-openapi

unused import: `body::Bytes`
pub use std::collections::BTreeMap;
pub use std::{
str::FromStr,
sync::Arc,
Expand Down Expand Up @@ -105,7 +106,7 @@
main: Arc<Client>,

/// Clients for all known nodes
cluster: HashMap<NodeName, Arc<Client>>,
cluster: BTreeMap<NodeName, Arc<Client>>,

context_marker: PhantomData<fn(Context)>,
}
Expand Down Expand Up @@ -168,7 +169,7 @@
.attach_printable(format!("Hostname: {}", hostname.to_string()))?
};

let cluster: HashMap<NodeName, Arc<_>> = nodes
let cluster: BTreeMap<NodeName, Arc<_>> = nodes
.iter()
.filter_map(|node| HttpClient::from_node(node, &bob_data.hostname, context.clone()))
.collect();
Expand All @@ -177,6 +178,7 @@
id: Uuid::new_v4(),
hostname: bob_data.hostname,
main: Arc::new(client.with_context(context)),
// main: Arc::new(client),
cluster,
context_marker: PhantomData,
})
Expand Down Expand Up @@ -275,7 +277,7 @@
}

#[must_use]
pub const fn cluster_with_addr(&self) -> &HashMap<NodeName, Arc<ApiInterface>> {
pub const fn cluster_with_addr(&self) -> &BTreeMap<NodeName, Arc<ApiInterface>> {
&self.cluster
}

Expand Down
Loading
Loading