From 52a032d3446c0880be8397c209e33338825f8ffd Mon Sep 17 00:00:00 2001 From: Afreen Rahman Date: Mon, 29 Jul 2019 20:18:52 +0530 Subject: [PATCH] Bug-fix: Updation Of Prometheus Queries change of num pools query in health card change of savings query in object data reduction card change of system name query in details card Signed-off-by: Afreen Rahman --- .../src/components/details-card/details-card.tsx | 4 ++-- .../src/components/health-card/health-card.tsx | 2 +- .../object-data-reduction-card-item.tsx | 7 ++++--- .../object-data-reduction-card.tsx | 11 +++++++---- .../packages/noobaa-storage-plugin/src/queries.ts | 13 +++++++------ 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/frontend/packages/noobaa-storage-plugin/src/components/details-card/details-card.tsx b/frontend/packages/noobaa-storage-plugin/src/components/details-card/details-card.tsx index 44124e57d6a9..328723931473 100644 --- a/frontend/packages/noobaa-storage-plugin/src/components/details-card/details-card.tsx +++ b/frontend/packages/noobaa-storage-plugin/src/components/details-card/details-card.tsx @@ -22,7 +22,7 @@ const getInfrastructurePlatform = (infrastructure: K8sResourceKind): string => const getCephVersion = (cephCluster: K8sResourceKind): string => _.get(cephCluster, 'spec.cephVersion.image'); -const NOOBAA_SYSTEM_NAME_QUERY = 'NooBaa_system_name'; +const NOOBAA_SYSTEM_NAME_QUERY = 'NooBaa_system_info'; const cephClusterResource: FirehoseResource = { kind: referenceForModel(CephClusterModel), @@ -62,7 +62,7 @@ export const ObjectServiceDetailsCard: React.FC = ({ const queryResult = prometheusResults.getIn([NOOBAA_SYSTEM_NAME_QUERY, 'result']); - const systemName = _.get(queryResult, 'data.result[0].metric.name'); + const systemName = _.get(queryResult, 'data.result[0].metric.system_name'); const infrastructure = _.get(resources, 'infrastructure'); const infrastructureLoaded = _.get(infrastructure, 'loaded', false); diff --git a/frontend/packages/noobaa-storage-plugin/src/components/health-card/health-card.tsx b/frontend/packages/noobaa-storage-plugin/src/components/health-card/health-card.tsx index ac6303e9925b..81bc06b4c7c2 100644 --- a/frontend/packages/noobaa-storage-plugin/src/components/health-card/health-card.tsx +++ b/frontend/packages/noobaa-storage-plugin/src/components/health-card/health-card.tsx @@ -74,7 +74,7 @@ const getObjectStorageHealthState = ( } } if (!_.isNil(buckets) && !_.isNil(unhealthyBuckets)) { - value = Number((Number(unhealthyBuckets) / Number(buckets)).toFixed(1)); + value = Number(unhealthyBuckets) / Number(buckets); if (value >= 0.5) { result.message = 'Many buckets have issues'; result.state = HealthState.ERROR; diff --git a/frontend/packages/noobaa-storage-plugin/src/components/object-data-reduction-card/object-data-reduction-card-item.tsx b/frontend/packages/noobaa-storage-plugin/src/components/object-data-reduction-card/object-data-reduction-card-item.tsx index 10c627810d91..638c54277919 100644 --- a/frontend/packages/noobaa-storage-plugin/src/components/object-data-reduction-card/object-data-reduction-card-item.tsx +++ b/frontend/packages/noobaa-storage-plugin/src/components/object-data-reduction-card/object-data-reduction-card-item.tsx @@ -50,13 +50,14 @@ export const SavingsItem: React.FC = React.memo( text = ; } else if (!_.isNil(savings)) { const savingsPercentage = logicalSize - ? humanizePercentage((100 * Number(savings)) / Number(logicalSize)) + ? `(${humanizePercentage((100 * Number(savings)) / logicalSize).string})` : null; const savingsFormattted = humanizeBinaryBytesWithoutB(Number(savings)); text = ( {savingsFormattted.value} - {savingsFormattted.unit}({savingsPercentage.string}) + {savingsFormattted.unit} + {savingsPercentage} ); } @@ -83,6 +84,6 @@ type EfficiencyItemProps = { type SavingsItemProps = { savings: string; - logicalSize: string; + logicalSize: number; isLoading: boolean; }; diff --git a/frontend/packages/noobaa-storage-plugin/src/components/object-data-reduction-card/object-data-reduction-card.tsx b/frontend/packages/noobaa-storage-plugin/src/components/object-data-reduction-card/object-data-reduction-card.tsx index 2f2866d1f777..c25f8b3086e6 100644 --- a/frontend/packages/noobaa-storage-plugin/src/components/object-data-reduction-card/object-data-reduction-card.tsx +++ b/frontend/packages/noobaa-storage-plugin/src/components/object-data-reduction-card/object-data-reduction-card.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import * as _ from 'lodash'; import { DashboardCard, DashboardCardBody, @@ -38,10 +37,14 @@ const DataReductionCard: React.FC = ({ ObjectDataReductionQueries.SAVINGS_QUERY, 'result', ]); + const logicalSavingsQueryResult = prometheusResults.getIn([ + ObjectDataReductionQueries.LOGICAL_SAVINGS_QUERY, + 'result', + ]); const efficiency = getPropsData(efficiencyQueryResult); const savings = getPropsData(savingsQueryResult); - const logicalSize = _.get(savingsQueryResult, 'data.result[0].metric.logical_size', null); + const logicalSize = getPropsData(logicalSavingsQueryResult); const efficiencyProps = { efficiency, @@ -50,8 +53,8 @@ const DataReductionCard: React.FC = ({ const savingsProps = { savings, - logicalSize, - isLoading: !savingsQueryResult, + logicalSize: Number(logicalSize), + isLoading: !savingsQueryResult && !logicalSavingsQueryResult, }; return ( diff --git a/frontend/packages/noobaa-storage-plugin/src/queries.ts b/frontend/packages/noobaa-storage-plugin/src/queries.ts index e9e085fd56c7..5c5910c761dc 100644 --- a/frontend/packages/noobaa-storage-plugin/src/queries.ts +++ b/frontend/packages/noobaa-storage-plugin/src/queries.ts @@ -3,16 +3,17 @@ export enum DATA_RESILIENCE_QUERIES { REBUILD_TIME_QUERY = 'NooBaa_rebuild_time', } -export const ObjectDataReductionQueries = { - EFFICIENCY_QUERY: 'NooBaa_reduction_ratio', - SAVINGS_QUERY: 'NooBaa_object_savings', -}; +export enum ObjectDataReductionQueries { + EFFICIENCY_QUERY = 'NooBaa_reduction_ratio', + SAVINGS_QUERY = '(NooBaa_object_savings_logical_size - NooBaa_object_savings_physical_size) > 0', + LOGICAL_SAVINGS_QUERY = 'NooBaa_object_savings_logical_size', +} export enum HealthCardQueries { BUCKETS_COUNT = 'NooBaa_num_buckets', UNHEALTHY_BUCKETS = 'NooBaa_num_unhealthy_buckets', - POOLS_COUNT = 'Noobaa_num_pools', - UNHEALTHY_POOLS = 'Noobaa_num_unhealthy_pools', + POOLS_COUNT = 'NooBaa_num_pools', + UNHEALTHY_POOLS = 'NooBaa_num_unhealthy_pools', } export const ObjectCapacityQueries = {