Skip to content

Commit

Permalink
Provide osd migration status alert for dr brownfield
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy Asir Jeyasingh <[email protected]>
  • Loading branch information
TimothyAsirJeyasing committed Nov 20, 2023
1 parent e71d640 commit ca42c91
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 1 deletion.
1 change: 1 addition & 0 deletions locales/en/plugin__odf-console.json
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@
"Internal": "Internal",
"Raw capacity is the absolute total disk space available to the array subsystem.": "Raw capacity is the absolute total disk space available to the array subsystem.",
"Troubleshoot": "Troubleshoot",
"OSDs migration is successful. Your cluster is ready for a regional DR setup.": "OSDs migration is successful. Your cluster is ready for a regional DR setup.",
"Active health checks": "Active health checks",
"Progressing": "Progressing",
"The Compression Ratio represents the compressible data effectiveness metric inclusive of all compression-enabled pools.": "The Compression Ratio represents the compressible data effectiveness metric inclusive of all compression-enabled pools.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,17 @@
text-decoration: none;
}
}

.mco-osd-migration {
display: flex;
margin-top:10px;
margin-left: 25px;
margin-bottom: 10px;
}

.mco-osd-migration-description {
display: flex;
flex-direction: column;
margin-left: 15px;
}

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
CardHeader,
CardTitle,
} from '@patternfly/react-core';
import CephClusterOSDMigrationStatus from '../../../modals/osd-migration/osd-migration-status';
import { CephClusterModel } from '../../../models';
import { DATA_RESILIENCY_QUERY, StorageDashboardQuery } from '../../../queries';
import { getCephHealthState, getDataResiliencyState } from './utils';
Expand Down Expand Up @@ -189,6 +190,7 @@ export const StatusCard: React.FC = () => {
</GalleryItem>
</Gallery>
</HealthBody>
<CephClusterOSDMigrationStatus data={data} />
<CephAlerts />
</Card>
);
Expand Down
64 changes: 64 additions & 0 deletions packages/ocs/modals/osd-migration/osd-migration-status.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import * as React from 'react';
import { GreenCheckCircleIcon } from '@odf/shared/status/icons';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import { K8sResourceKind } from '@openshift-console/dynamic-plugin-sdk';
import { InProgressIcon } from '@patternfly/react-icons';
import { OSDMigrationStatus, getOSDMigrationStatus } from '../../utils/ocs';

const CephClusterOSDMigrationStatus: React.FC<CephClusterOSDMigrationStatusProps> =
({ data }) => {
const { t } = useCustomTranslation();
const osdMigrationStatus = getOSDMigrationStatus(data[0]);
let description: string | null = null;
let IconComponent: React.ComponentType<any> = () => null;

if (osdMigrationStatus === OSDMigrationStatus.IN_PROGRESS) {
const migratedDevices =
data[0]?.status?.storage?.osd?.storeType?.['bluestore-rdr'] || 0;
const totalOsd =
data[0]?.status?.storage?.osd?.storeType?.bluestar ||
0 + migratedDevices;
const percentageComplete =
totalOsd !== 0 ? Math.round((migratedDevices / totalOsd) * 100) : 0;
description = t(
`Cluster is undergoing OSDs migration. ${percentageComplete}% completed (${migratedDevices}/${totalOsd} remaining)`
);
IconComponent = InProgressIcon;
} else if (osdMigrationStatus === OSDMigrationStatus.COMPLETED) {
description = t(
'OSDs migration is successful. Your cluster is ready for a regional DR setup.'
);
IconComponent = GreenCheckCircleIcon;
}

return (
<div>
<hr />
{description && (
<div className="mco-osd-migration">
<div
data-test="Storage Cluster-health-item-icon"
className="co-dashboard-icon"
>
<IconComponent />
</div>
<div>
<span
className="mco-osd-migration-description"
data-test="osd-migration-description"
>
{description}
</span>
</div>
</div>
)}
<hr />
</div>
);
};

export default CephClusterOSDMigrationStatus;

type CephClusterOSDMigrationStatusProps = {
data?: K8sResourceKind[];
};
34 changes: 34 additions & 0 deletions packages/ocs/utils/ocs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { DISASTER_RECOVERY_TARGET_ANNOTATION } from '@odf/core/constants';
import { getAnnotations } from '@odf/shared/selectors';
import { CephClusterKind } from '@odf/shared/types';

export enum OSDMigrationStatus {
IN_PROGRESS = 'In Progress',
PENDING = 'Pending',
COMPLETED = 'Completed',
UNKNOWN = '',
}
const BLUESTORE_RDR = 'bluestore-rdr';
const BLUESTORE = 'bluestore';

export const getOSDMigrationStatus = (ceph: CephClusterKind) => {
if (!!ceph) {
const bluestoreCount = ceph?.status?.storage?.osd?.storeType?.[BLUESTORE];
const bluestoreRdrCount =
ceph?.status?.storage?.osd?.storeType?.[BLUESTORE_RDR];

const isDisasterRecoveryTarget =
getAnnotations(ceph)?.[DISASTER_RECOVERY_TARGET_ANNOTATION] === 'true';

if (bluestoreCount > 0) {
if (bluestoreRdrCount > 0 || isDisasterRecoveryTarget) {
return OSDMigrationStatus.IN_PROGRESS;
} else {
return OSDMigrationStatus.PENDING;
}
} else if (bluestoreRdrCount > 0) {
return OSDMigrationStatus.COMPLETED;
}
}
return OSDMigrationStatus.UNKNOWN;
};
8 changes: 7 additions & 1 deletion packages/shared/src/types/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ type CephDeviceClass = {

export type CephClusterKind = K8sResourceCommon & {
status?: {
storage: {
storage?: {
osd?: {
storeType?: {
bluestore?: number;
'bluestore-rdr'?: number;
};
};
deviceClasses: CephDeviceClass[];
};
ceph?: {
Expand Down

0 comments on commit ca42c91

Please sign in to comment.