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

[7] Detailed Node Page (frontend) #25

Draft
wants to merge 6 commits into
base: 8-vdisk-list-frontend
Choose a base branch
from
Draft
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 @@ -18,3 +18,4 @@ Bob Management GUI changelog
- Home page, frontend (#22)
- Node list page, frontend (#23)
- VDisk list page, backend (#20)
- Detailed node information page, backend (#21)
97 changes: 97 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,37 @@ paths:
description: Node Not Found
security:
- api_key: []
/api/v1/nodes/{node_name}/detailed:
get:
tags:
- services::api
summary: Get Detailed Information on Node
description: |-
Get Detailed Information on Node

# Errors

This function will return an error if the server was unable to get node'a client
or one of the requests to get information from the node fails
operationId: get_detailed_node_info
parameters:
- name: id
in: path
description: Node's ID
required: true
responses:
'200':
description: Detailed Node information
content:
application/json:
schema:
$ref: '#/components/schemas/DetailedNode'
'401':
description: Unauthorized
'404':
description: Node Not Found
security:
- api_key: []
/api/v1/nodes/{node_name}/metrics:
get:
tags:
Expand Down Expand Up @@ -334,6 +365,72 @@ components:
example:
login: archeoss
password: '12345'
DetailedNode:
type: object
required:
- name
- hostname
- vdisks
- status
- metrics
- disks
properties:
disks:
type: array
items:
$ref: '#/components/schemas/Disk'
hostname:
type: string
metrics:
$ref: '#/components/schemas/DetailedNodeMetrics'
name:
type: string
status:
$ref: '#/components/schemas/NodeStatus'
vdisks:
type: array
items:
$ref: '#/components/schemas/VDisk'
DetailedNodeMetrics:
type: object
required:
- rps
- alienCount
- corruptedCount
- space
- cpuLoad
- totalRam
- usedRam
- descrAmount
properties:
alienCount:
type: integer
format: int64
minimum: 0
corruptedCount:
type: integer
format: int64
minimum: 0
cpuLoad:
type: integer
format: int64
minimum: 0
descrAmount:
type: integer
format: int64
minimum: 0
rps:
$ref: '#/components/schemas/RPS'
space:
$ref: '#/components/schemas/SpaceInfo'
totalRam:
type: integer
format: int64
minimum: 0
usedRam:
type: integer
format: int64
minimum: 0
Disk:
type: object
description: Physical disk definition
Expand Down
2 changes: 2 additions & 0 deletions backend/src/connector/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//!

use std::collections::HashMap;
use tsync::tsync;
#[cfg(all(feature = "swagger", debug_assertions))]
use utoipa::ToSchema;

Expand Down Expand Up @@ -365,6 +366,7 @@ impl std::str::FromStr for Error {
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
#[tsync]
pub struct MetricsEntryModel {
#[serde(rename = "value")]
pub value: u64,
Expand Down
3 changes: 3 additions & 0 deletions backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ impl Modify for SecurityAddon {
services::api::get_space,
services::api::raw_metrics_by_node,
services::api::raw_configuration_by_node,
services::api::get_detailed_node_info,
services::api::get_node_info,
services::api::get_nodes_list,
services::api::get_vdisk_info,
Expand All @@ -66,6 +67,8 @@ impl Modify for SecurityAddon {
models::api::SpaceInfo,
models::api::VDisk,
models::api::VDiskStatus,
models::api::DetailedNode,
models::api::DetailedNodeMetrics,
models::api::Operation,
models::api::RPS,
models::api::RawMetricEntry,
Expand Down
93 changes: 93 additions & 0 deletions backend/src/models/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,37 @@ pub struct Disk {
pub iops: u64,
}

impl Disk {
#[must_use]
pub fn from_metrics(
disk_name: String,
disk_path: String,
raw_metrics: &dto::MetricsSnapshotModel,
raw_space: &dto::SpaceInfo,
) -> Self {
let status = DiskStatus::from_space_info(raw_space, &disk_name);
let used_space = raw_space
.occupied_disk_space_by_disk
.get(&disk_name)
.copied()
.unwrap_or_default();
let iops = raw_metrics
.metrics
.get(&format!("hardware.disks.{:?}_iops", disk_name))
.cloned()
.unwrap_or_default()
.value;
Self {
name: disk_name,
path: disk_path,
status,
total_space: raw_space.total_disk_space_bytes,
used_space,
iops,
}
}
}

/// Defines kind of problem on disk
#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Serialize, Hash)]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
Expand Down Expand Up @@ -191,6 +222,12 @@ pub enum NodeStatus {
Offline,
}

impl Default for NodeStatus {
fn default() -> Self {
Self::Offline
}
}

impl NodeStatus {
#[must_use]
pub fn from_problems(problems: Vec<NodeProblem>) -> Self {
Expand Down Expand Up @@ -349,6 +386,62 @@ pub enum VDiskStatus {
Offline,
}

#[derive(Default, Debug, Clone, Serialize)]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
#[tsync]
pub struct DetailedNode {
pub name: String,

pub hostname: String,

pub vdisks: Vec<VDisk>,

// #[serde(flatten)]
pub status: NodeStatus,

pub metrics: DetailedNodeMetrics,

pub disks: Vec<Disk>,
}

#[derive(Default, Debug, Clone, Serialize)]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
#[serde(rename_all = "camelCase")]
#[tsync]
pub struct DetailedNodeMetrics {
pub rps: RPS,

pub alien_count: u64,

pub corrupted_count: u64,

pub space: SpaceInfo,

pub cpu_load: u64,

pub total_ram: u64,

pub used_ram: u64,

pub descr_amount: u64,
}

impl DetailedNodeMetrics {
#[must_use]
pub fn from_metrics(metrics: &TypedMetrics, space: SpaceInfo) -> Self {
Self {
rps: RPS::from_metrics(metrics),
alien_count: metrics[RawMetricEntry::BackendAlienCount].value,
corrupted_count: metrics[RawMetricEntry::BackendCorruptedBlobCount].value,
space,
cpu_load: metrics[RawMetricEntry::HardwareBobCpuLoad].value,
total_ram: metrics[RawMetricEntry::HardwareTotalRam].value,
used_ram: metrics[RawMetricEntry::HardwareUsedRam].value,
descr_amount: metrics[RawMetricEntry::HardwareDescrAmount].value,
}
}
}

/// Types of operations on BOB cluster
#[derive(Debug, Clone, Serialize, Hash, Eq, PartialEq, PartialOrd, Ord, EnumIter)]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
Expand Down
Loading
Loading