Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1999717: Block and File and Object dashboards should not be part of OCP Console for ODF Managed Services #9952

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -95,7 +95,8 @@
"href": "/ocs-dashboards"
},
"flags": {
"required": ["OCS"]
"required": ["OCS"],
"disallowed": ["ODF_MANAGED"]
}
},
{
Expand Down
Expand Up @@ -15,20 +15,31 @@ import {
isDashboardsCard as isDynamicDashboardsCard,
isDashboardsTab as isDynamicDashboardsTab,
} from '@console/dynamic-plugin-sdk';
import { useFlag } from '@console/shared/src/hooks/flag';
import {
getPluginTabPages,
mapStateToProps,
DashboardsPageProps,
} from '@console/internal/components/dashboard/dashboards-page/dashboards';
import { HorizontalNav, PageHeading, LoadingBox } from '@console/internal/components/utils';
import { OCS_INDEPENDENT_FLAG, MCG_FLAG, CEPH_FLAG } from '../../features';

const OCSDashboardsPage: React.FC<DashboardsPageProps> = ({ match, kindsInFlight, k8sModels }) => {
const { t } = useTranslation();
const title = t('ceph-storage-plugin~OpenShift Container Storage Overview');
const isIndependent = useFlag(OCS_INDEPENDENT_FLAG);
const isObjectServiceAvailable = useFlag(MCG_FLAG);
const isCephAvailable = useFlag(CEPH_FLAG);
const tabExtensions = useExtensions<DashboardsTab>(isDashboardsTab);
const cardExtensions = useExtensions<DashboardsCard>(isDashboardsCard);
const dynamicTabExtensions = useExtensions<DynamicDashboardsTab>(isDynamicDashboardsTab);
const dynamicCardExtensions = useExtensions<DynamicDashboardsCard>(isDynamicDashboardsCard);
const firstTabId =
isIndependent && isCephAvailable
? 'independent-dashboard'
: isObjectServiceAvailable && !isCephAvailable
? 'object-service'
: 'persistent-storage';

const pluginPages = React.useMemo(
() =>
Expand All @@ -37,9 +48,9 @@ const OCSDashboardsPage: React.FC<DashboardsPageProps> = ({ match, kindsInFlight
cardExtensions,
dynamicCardExtensions,
'storage',
'persistent-storage',
firstTabId,
),
[tabExtensions, dynamicTabExtensions, cardExtensions, dynamicCardExtensions],
[tabExtensions, dynamicTabExtensions, cardExtensions, dynamicCardExtensions, firstTabId],
);

return kindsInFlight && k8sModels.size === 0 ? (
Expand Down
Expand Up @@ -32,6 +32,7 @@ export const MINIMUM_NODES = 3;
export const SECOND = 1000;
export const OCS_NS = 'openshift-storage';
export const NB_PROVISIONER = 'noobaa.io/obc';
export const ODF_MANAGED_LABEL = 'odf-managed-service';
export enum StoreType {
BS = 'BackingStore',
NS = 'NamespaceStore',
Expand Down
19 changes: 17 additions & 2 deletions frontend/packages/ceph-storage-plugin/src/features.ts
@@ -1,6 +1,6 @@
import * as _ from 'lodash';
import { Dispatch } from 'react-redux';
import { k8sList, StorageClassResourceKind, ListKind } from '@console/internal/module/k8s';
import { k8sGet, k8sList, StorageClassResourceKind, ListKind } from '@console/internal/module/k8s';
import {
ClusterServiceVersionModel,
ClusterServiceVersionKind,
Expand All @@ -9,7 +9,7 @@ import { setFlag } from '@console/internal/actions/features';
import { FeatureDetector } from '@console/plugin-sdk';
import { getAnnotations, getName } from '@console/shared/src/selectors/common';
import { fetchK8s } from '@console/internal/graphql/client';
import { StorageClassModel } from '@console/internal/models';
import { NamespaceModel, StorageClassModel } from '@console/internal/models';
import { OCSServiceModel, CephClusterModel, NooBaaSystemModel } from './models';
import {
CEPH_STORAGE_NAMESPACE,
Expand All @@ -18,12 +18,15 @@ import {
SECOND,
OCS_OPERATOR,
NOOBAA_PROVISIONER,
ODF_MANAGED_LABEL,
} from './constants';
import { StorageClusterKind } from './types';

export const OCS_INDEPENDENT_FLAG = 'OCS_INDEPENDENT';
export const OCS_CONVERGED_FLAG = 'OCS_CONVERGED';

export const ODF_MANAGED_FLAG = 'ODF_MANAGED';

export const LSO_FLAG = 'LSO';

export const RGW_FLAG = 'RGW';
Expand Down Expand Up @@ -139,6 +142,18 @@ export const detectOCS: FeatureDetector = async (dispatch) => {
}
};

export const detectManagedODF: FeatureDetector = async (dispatch) => {
try {
const ns = await k8sGet(NamespaceModel, CEPH_STORAGE_NAMESPACE);
if (ns) {
const isManagedCluster = ns?.metadata?.labels?.[ODF_MANAGED_LABEL];
dispatch(setFlag(ODF_MANAGED_FLAG, !!isManagedCluster));
}
} catch (error) {
dispatch(setFlag(ODF_MANAGED_FLAG, false));
}
};

export const detectComponents: FeatureDetector = async (dispatch) => {
let id = null;
let noobaaFound = false;
Expand Down
23 changes: 23 additions & 0 deletions frontend/packages/ceph-storage-plugin/src/plugin.ts
Expand Up @@ -39,6 +39,8 @@ import {
MCG_FLAG,
OCS_FLAG,
detectComponents,
ODF_MANAGED_FLAG,
detectManagedODF,
} from './features';
import { getObcStatusGroups } from './components/dashboards/object-service/buckets-card/utils';

Expand Down Expand Up @@ -107,6 +109,15 @@ const plugin: Plugin<ConsumedExtensions> = [
required: [MCG_FLAG],
},
},
{
type: 'FeatureFlag/Custom',
properties: {
detect: detectManagedODF,
},
flags: {
required: [OCS_MODEL_FLAG],
},
},
{
type: 'FeatureFlag/Custom',
properties: {
Expand Down Expand Up @@ -652,6 +663,18 @@ const plugin: Plugin<ConsumedExtensions> = [
},
flags: {
required: [OCS_FLAG],
disallowed: [ODF_MANAGED_FLAG],
},
},
{
type: 'Page/Route',
properties: {
path: `/ocs-dashboards`,
loader: () => import('./components/dashboards/ocs-dashboards').then((m) => m.DashboardsPage),
},
flags: {
required: [MCG_FLAG],
disallowed: [OCS_FLAG],
},
},
{
Expand Down