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

refactoring (support multiple StorageSystems per ODF) #1106

Conversation

SanjalKatiyar
Copy link
Collaborator

@SanjalKatiyar SanjalKatiyar commented Nov 23, 2023

  • Removed OCS related flags from "features.ts" file.
  • Added those flags as a part of redux store and created releated utils.
  • Created Hook to read these flags.
  • Updated Wizard to support multiple Ceph based clusters (only 1 internal + 1 external needed for now).
  • Updated KMS resources creation utils (Secrets) so that CSI and OCS resources are de-coupled.
  • Added a Namespace field to OCS wizard redux (used across entire wizard flow).
  • Updated dashboards so that each StorageCluster should only show related components, not any/all (NooBaa/RGW).
  • Updated StorageCluster dashboard Routes by adding Namespace as well.
  • Updated all queries using "odf_system_" and "ceph_" metrics, relying on "managedBy" label for now (Block/File/Object).
  • Updated StorageClass creation flow (ceph-rbd/fs) with a dropdown for corresponding StorageSystem selection.
  • Updated "HealthOverview" (injected to OCP dashboard's Status card currently) to incorporate status of all Ceph clusters.
Screenshot 2023-12-05 at 12 22 11 PM Screenshot 2023-12-05 at 12 22 31 PM Screenshot 2023-12-05 at 12 22 43 PM

@SanjalKatiyar SanjalKatiyar force-pushed the multiple_sc_refactor_ss_support branch 5 times, most recently from 70d7ccc to 1163588 Compare November 27, 2023 16:17
@SanjalKatiyar SanjalKatiyar force-pushed the multiple_sc_refactor_ss_support branch 7 times, most recently from 20754a1 to c71a477 Compare November 30, 2023 12:50
@SanjalKatiyar SanjalKatiyar force-pushed the multiple_sc_refactor_ss_support branch 4 times, most recently from 86a81cc to 36bebf9 Compare December 1, 2023 13:55
@SanjalKatiyar SanjalKatiyar force-pushed the multiple_sc_refactor_ss_support branch from 36bebf9 to fc03a5a Compare December 4, 2023 09:54
@SanjalKatiyar SanjalKatiyar force-pushed the multiple_sc_refactor_ss_support branch 4 times, most recently from f6c8d86 to fd93a4c Compare December 5, 2023 07:02
@SanjalKatiyar SanjalKatiyar changed the title [WIP] refactoring (support multiple StorageSystems per ODF) refactoring (support multiple StorageSystems per ODF) Dec 5, 2023
Comment on lines +39 to +40
const OCS_INTERNAL_CR_NAME = 'ocs-storagecluster';
const OCS_EXTERNAL_CR_NAME = 'ocs-external-storagecluster';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only keeping it here as this should not be used at any other place... for now name of the clusters are constant so passing them directly from this file during creation, later if needed, we should make it an user input...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these constant values should not be used in any other flow, except wizard flow for cluster creation...

);
const systemNamespace = getNamespace(storageSystem);
const ocsHealthStatus =
ocsHealthStatuses[systemName + systemNamespace];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no separator symbol in between? just asking

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need, as I don't want to separate them later into name and namespace...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets use templates instead of +

return systems.reduce<SystemMetrics>((acc, curr) => {
acc[curr.metadata.name] = {
acc[getName(curr) + getNamespace(curr)] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name + namespace key is used in multiple places, it is better to create one util function to form a key out of an argument with some separator symbol in between, so we can change this key format anytime. And we can easily figureout what are all the places need to be changed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

Comment on lines 46 to 50
export const isMCGStandaloneCluster = (storageCluster: StorageClusterKind) => {
return (
storageCluster?.spec?.multiCloudGateway?.reconcileStrategy === 'standalone'
);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const isMCGStandaloneCluster = (storageCluster: StorageClusterKind) => {
return (
storageCluster?.spec?.multiCloudGateway?.reconcileStrategy === 'standalone'
);
};
export const isMCGStandaloneCluster = (storageCluster: StorageClusterKind) =>
storageCluster?.spec?.multiCloudGateway?.reconcileStrategy === 'standalone';

Comment on lines 52 to 54
export const isExternalCluster = (storageCluster: StorageClusterKind) => {
return !_.isEmpty(storageCluster?.spec?.externalStorage);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const isExternalCluster = (storageCluster: StorageClusterKind) => {
return !_.isEmpty(storageCluster?.spec?.externalStorage);
};
export const isExternalCluster = (storageCluster: StorageClusterKind) =>
!_.isEmpty(storageCluster?.spec?.externalStorage);

Comment on lines 56 to 58
export const isClusterIgnored = (storageCluster: StorageClusterKind) => {
return storageCluster?.status?.phase === 'Ignored';
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const isClusterIgnored = (storageCluster: StorageClusterKind) => {
return storageCluster?.status?.phase === 'Ignored';
};
export const isClusterIgnored = (storageCluster: StorageClusterKind) =>
storageCluster?.status?.phase === 'Ignored';

Comment on lines 60 to 62
export const isNFSEnabled = (storageCluster: StorageClusterKind) => {
return storageCluster?.spec?.nfs?.enable === true;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const isNFSEnabled = (storageCluster: StorageClusterKind) => {
return storageCluster?.spec?.nfs?.enable === true;
};
export const isNFSEnabled = (storageCluster: StorageClusterKind) =>
storageCluster?.spec?.nfs?.enable === true;

@@ -317,7 +322,7 @@ const CapacityCard: React.FC<CapacityCardProps> = ({
const isPercentage = !!item?.totalValue;
return (
<CapacityCardRow
key={item.name}
key={item.name + item.namespace}
Copy link
Contributor

@GowthamShanmugam GowthamShanmugam Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, better create util function to get the key with separator like name-namesapce

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need a separator as I do not want to parse/separate name and namespace later... also util might not be of any use because at some components we already have access to name/namespace and we just need to combine them, other place they are the CR and some places like this one a custom object... so single util will not gonna work any way...

@SanjalKatiyar SanjalKatiyar force-pushed the multiple_sc_refactor_ss_support branch from fd93a4c to 2d46312 Compare December 8, 2023 06:04
@SanjalKatiyar
Copy link
Collaborator Author

/test odf-console-e2e-aws

@SanjalKatiyar SanjalKatiyar force-pushed the multiple_sc_refactor_ss_support branch 2 times, most recently from 1480d67 to a37b1e1 Compare December 8, 2023 10:39
@GowthamShanmugam
Copy link
Contributor

LGTM

@SanjalKatiyar
Copy link
Collaborator Author

SanjalKatiyar commented Dec 11, 2023

CI un-blocked by: #1125 (PR#1125 is needed because of OCP react-router-dom updates, else components using imports will break).

@@ -66,21 +62,24 @@ const CreateBlockPool: React.FC<CreateBlockPoolProps> = ({
const { t } = useCustomTranslation();

const history = useHistory();
const { namespace: poolNs } = useParams<ODFSystemParams>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { namespace: poolNs } = useParams<ODFSystemParams>();
const { namespace } = useParams<ODFSystemParams>();

Lets just use namespace.

{ systemName, targetKind, clusterName, totalValue, usedValue, clusterURL },
{
systemName,
namespace: systemNamespace,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to rename the variable? IMO namespace is pretty clear to understand.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have 2 namespaces now: odfNamespace (where ODF is installed) and systemNamespace (where system is getting created), even though both are not used here still IMO it is good to rename things accordingly, it is harmless, rather a bit more intuitive :(

@@ -30,18 +29,15 @@ export const BlockPoolDetailsPage: React.FC<BlockPoolDetailsPageProps> = ({

const { poolName } = match.params;
const location = useLocation();
const { namespace: poolNs } = useParams<ODFSystemParams>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { namespace: poolNs } = useParams<ODFSystemParams>();
const { namespace } = useParams<ODFSystemParams>();

I think it is clear as it is.

@@ -226,13 +222,15 @@ const RowRenderer: React.FC<RowProps<StoragePoolKind, CustomData>> = ({
}) => {
const { t } = useCustomTranslation();

const { systemFlags } = useODFSystemFlagsSelector();
const isExternalSS = systemFlags[getNamespace(obj)]?.isExternalMode;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isExternalSS = systemFlags[getNamespace(obj)]?.isExternalMode;
const isExternalStorageSystem = systemFlags[getNamespace(obj)]?.isExternalMode;

};
}, [scs, ccs, coss, nss, allLoaded, anyError]);

return useDeepCompareMemoize(payload);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return useDeepCompareMemoize(payload);
return useDeepCompareMemoize(payload, true);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's intensional to minimise number of dispatches to the redux... payload will not be too long or too deep object...

<div className="odf-topology__message-button">
<BlueInfoCircleIcon />{' '}
{showMessage &&
t('This view is only supported for Internal mode cluster.')}{' '}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t('This view is only supported for Internal mode cluster.')}{' '}
t('This view is only supported for Internal mode cluster.')}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need that extra space between this text and the show/hide button...

@@ -27,6 +27,16 @@
z-index: 2;
}

.odf-topology__message-button {
color: #393F44;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use PF variables.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something which I copied from already existing class odf-topology__back-button, just above this one... this is something which needs to be corrected once at all the places (probably is separate CSS based PR)...

hasOCS,
// both internal and external exists
haveMultipleClusters,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
haveMultipleClusters,
hasMultipleClusters,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok...

);
const systemNamespace = getNamespace(storageSystem);
const ocsHealthStatus =
ocsHealthStatuses[systemName + systemNamespace];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets use templates instead of +

Comment on lines +23 to +26
const { namespace: clusterNs } = useParams<ODFSystemParams>();
const { systemFlags } = useODFSystemFlagsSelector();
const managedByOCS = systemFlags[clusterNs]?.ocsClusterName;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets use it as it is. Redux store is passed as a context so do we need multiple contexts?

@SanjalKatiyar SanjalKatiyar force-pushed the multiple_sc_refactor_ss_support branch 2 times, most recently from bcafa7a to 5b9fc91 Compare December 12, 2023 08:50
@bipuladh
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Dec 12, 2023
@SanjalKatiyar SanjalKatiyar force-pushed the multiple_sc_refactor_ss_support branch from 5b9fc91 to 617a945 Compare December 12, 2023 14:28
@openshift-ci openshift-ci bot removed the lgtm label Dec 12, 2023
Removed OCS related flags from "features.ts" file.
Added those flags as a part of redux store and created releated utils.
Created Hook to read these flags.
Updated Wizard to support multiple Ceph based clusters (only 1 internal + 1 external needed for now).
Updated KMS resources creation utils (Secrets) so that CSI and OCS resources are de-coupled.
Added a Namespace field to OCS wizard redux (used across entire wizard flow).
Updated dashboards so that each StorageCluster should only show related components, not any/all (NooBaa/RGW).
Updated StorageCluster dashboard Routes by adding Namespace as well.
Updated all queries using "odf_system_" and "ceph_" metrics, relying on "managedBy" label for now (Block/File/Object).
Updated StorageClass creation flow (ceph-rbd/fs) with a dropdown for corresponding StorageSystem selection.
Updated "HealthOverview" (injected to OCP dashboard's Status card currently) to incorporate status of all Ceph clusters.
@SanjalKatiyar SanjalKatiyar force-pushed the multiple_sc_refactor_ss_support branch from 617a945 to 5516bd9 Compare December 12, 2023 14:35
@bipuladh
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Dec 12, 2023
Copy link
Contributor

openshift-ci bot commented Dec 12, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bipuladh, SanjalKatiyar

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [SanjalKatiyar,bipuladh]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit b8e0554 into red-hat-storage:master Dec 12, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants