Skip to content

Commit

Permalink
Adding 'Compression Savings' details to the pool list page
Browse files Browse the repository at this point in the history
This is on top of Gowtham's PR#9252, adding the compression details into
the pool list page.

Signed-off-by: Arun Kumar Mohan <amohan@redhat.com>
  • Loading branch information
aruniiird committed Jul 23, 2021
1 parent cdea2e7 commit 23a96a9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Expand Up @@ -136,6 +136,9 @@ const BlockPoolTableRow: React.FC<RowFunctionArgs> = ({ obj, index, key, style,
const rawCapacity: string = props.poolRawCapacity[name]
? humanizeBinaryBytes(props.poolRawCapacity[name]).string
: '-';
const compressionSavings: string = props.poolCompressionSavings[name]
? humanizeBinaryBytes(props.poolCompressionSavings[name]).string
: '-';

return (
<TableRow id={obj.metadata.uid} index={index} trKey={key} style={style}>
Expand Down Expand Up @@ -196,7 +199,7 @@ const BlockPoolTableRow: React.FC<RowFunctionArgs> = ({ obj, index, key, style,
className={blockPoolColumnInfo.compressionsavings.classes}
columnID={blockPoolColumnInfo.compressionsavings.id}
>
{'-'}
{compressionStatus ? compressionSavings : '-'}
</TableData>
<TableData className={Kebab.columnClass}>
<ResourceKebab
Expand Down Expand Up @@ -236,6 +239,17 @@ const BlockPoolList: React.FC<BlockPoolListProps> = (props) => {
rawCapLoadError,
rawCapLoading,
);
// compression queries
const [compressionSavings, compressionLoadError, compressionLoading] = usePrometheusPoll({
endpoint: PrometheusEndpoint.QUERY,
query: getPoolQuery(poolNames, StorageDashboardQuery.POOL_COMPRESSION_SAVINGS),
namespace: CEPH_STORAGE_NAMESPACE,
});
const poolCompressionSavings: PoolMetrics = getPerPoolMetrics(
compressionSavings,
compressionLoadError,
compressionLoading,
);

return (
<Table
Expand All @@ -247,6 +261,7 @@ const BlockPoolList: React.FC<BlockPoolListProps> = (props) => {
storageClasses: memoizedSC ?? [],
cephCluster: cephClusters?.[0],
poolRawCapacity,
poolCompressionSavings,
}}
virtualize
/>
Expand Down Expand Up @@ -281,6 +296,7 @@ type BlockPoolListRowProps = {
cephCluster: CephClusterKind;
storageClasses: OcsStorageClassKind[];
poolRawCapacity: PoolMetrics;
poolCompressionSavings: PoolMetrics;
};

type BlockPoolListProps = {
Expand Down
Expand Up @@ -29,6 +29,7 @@ export enum StorageDashboardQuery {
POOL_CAPACITY_RATIO = 'POOL_CAPACITY_RATIO',
POOL_SAVED_CAPACITY = 'POOL_SAVED_CAPACITY',
POOL_RAW_CAPACITY_USED = 'POOL_RAW_CAPACITY_USED',
POOL_COMPRESSION_SAVINGS = 'POOL_COMPRESSION_SAVINGS',
// Capacity Info Card
RAW_CAPACITY_TOTAL = 'RAW_TOTAL_CAPACITY',
RAW_CAPACITY_USED = 'RAW_CAPACITY_USED',
Expand Down Expand Up @@ -220,6 +221,7 @@ export const getPoolQuery = (poolNames: string[], queryName: string) => {
const names = poolNames.join('|');
const queries = {
[StorageDashboardQuery.POOL_RAW_CAPACITY_USED]: `ceph_pool_bytes_used * on (pool_id) group_left(name)ceph_pool_metadata{name=~'${names}'}`,
[StorageDashboardQuery.POOL_COMPRESSION_SAVINGS]: `(ceph_pool_compress_under_bytes - ceph_pool_compress_bytes_used) * on (pool_id) group_left(name)ceph_pool_metadata{name=~'${names}'}`,
};
return queries[queryName];
};

0 comments on commit 23a96a9

Please sign in to comment.