Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import {
withDashboardResources,
} from '@console/internal/components/dashboards-page/with-dashboard-resources';
import { DetailsBody } from '@console/internal/components/dashboard/details-card/details-body';
import { FirehoseResource } from '@console/internal/components/utils/index';
import { FirehoseResource, FirehoseResult } from '@console/internal/components/utils/index';
import { InfrastructureModel, SubscriptionModel } from '@console/internal/models/index';
import { K8sResourceKind } from '@console/internal/module/k8s/index';
import { getName } from '@console/shared/src/selectors/common';
import { referenceForModel } from '@console/internal/module/k8s/k8s';
import { CephClusterModel } from '../../../models';
import { getOCSVersion } from '../../../selectors';

const infrastructureResource: FirehoseResource = {
kind: referenceForModel(InfrastructureModel),
Expand All @@ -37,8 +38,7 @@ const SubscriptionResource: FirehoseResource = {
kind: referenceForModel(SubscriptionModel),
namespaced: false,
prop: 'subscription',
name: 'ocs-subscription',
isList: false,
isList: true,
};

const DetailsCard: React.FC<DashboardItemProps> = ({
Expand Down Expand Up @@ -67,9 +67,9 @@ const DetailsCard: React.FC<DashboardItemProps> = ({
const cephClusterData = _.get(cephCluster, 'data') as K8sResourceKind[];
const cephClusterName = getName(_.get(cephClusterData, 0));

const subscription = _.get(resources, 'subscription');
const subscription = _.get(resources, 'subscription') as FirehoseResult;
const subscriptionLoaded = _.get(subscription, 'loaded');
const ocsVersion = _.get(subscription, 'data.status.currentCSV');
const ocsVersion = getOCSVersion(subscription);

return (
<DashboardCard>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export const STORAGE_CLASSES = 'Storage Classes';
export const PODS = 'Pods';
export const BY_USED = 'By Used Capacity';
export const BY_REQUESTED = 'By Requested Capacity';
export const OCS_OPERATOR = 'ocs-operator';
11 changes: 11 additions & 0 deletions frontend/packages/ceph-storage-plugin/src/selectors/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as _ from 'lodash';
import { Alert } from '@console/internal/components/monitoring';
import { K8sResourceKind } from '@console/internal/module/k8s';
import { FirehoseResult } from '@console/internal/components/utils';
import { OCS_OPERATOR } from '../constants';

const cephStorageProvisioners = ['ceph.rook.io/block', 'cephfs.csi.ceph.com', 'rbd.csi.ceph.com'];
const cephStorageLabel = 'cluster.ocs.openshift.io/openshift-storage';
Expand Down Expand Up @@ -32,3 +34,12 @@ export const getCephSC = (scData: K8sResourceKind[]): K8sResourceKind[] =>
_.get(sc, 'provisioner', '').includes(provisioner),
);
});

export const getOCSVersion = (items: FirehoseResult): string => {
const itemsData: K8sResourceKind[] = _.get(items, 'data');
const operator: K8sResourceKind = _.find(
itemsData,
(item) => _.get(item, 'spec.name') === OCS_OPERATOR,
);
return _.get(operator, 'status.currentCSV');
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import {
DashboardItemProps,
withDashboardResources,
} from '@console/internal/components/dashboards-page/with-dashboard-resources';
import { FirehoseResource, ExternalLink } from '@console/internal/components/utils';
import { FirehoseResource, ExternalLink, FirehoseResult } from '@console/internal/components/utils';
import { InfrastructureModel, SubscriptionModel } from '@console/internal/models/index';
import { referenceForModel, K8sResourceKind } from '@console/internal/module/k8s';
import { getOCSVersion } from '@console/ceph-storage-plugin/src/selectors';
import { getMetric } from '../../utils';

const NOOBAA_SYSTEM_NAME_QUERY = 'NooBaa_system_info';
Expand All @@ -31,8 +32,7 @@ const SubscriptionResource: FirehoseResource = {
kind: referenceForModel(SubscriptionModel),
namespaced: false,
prop: 'subscription',
name: 'ocs-subscription',
isList: false,
isList: true,
};

export const ObjectServiceDetailsCard: React.FC<DashboardItemProps> = ({
Expand Down Expand Up @@ -66,9 +66,9 @@ export const ObjectServiceDetailsCard: React.FC<DashboardItemProps> = ({
const infrastructureData = _.get(infrastructure, 'data') as K8sResourceKind;
const infrastructurePlatform = getInfrastructurePlatform(infrastructureData);

const subscription = _.get(resources, 'subscription');
const subscription = _.get(resources, 'subscription') as FirehoseResult;
const subscriptionLoaded = _.get(subscription, 'loaded');
const ocsVersion = _.get(subscription, 'data.status.currentCSV');
const ocsVersion = getOCSVersion(subscription);

return (
<DashboardCard>
Expand Down