-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide osd migration status alert for dr brownfield
Signed-off-by: Timothy Asir Jeyasingh <[email protected]>
- Loading branch information
1 parent
e71d640
commit ca42c91
Showing
6 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/ocs/modals/osd-migration/osd-migration-status.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters