Skip to content

Commit

Permalink
Merge pull request #9836 from afreen23/two-systems
Browse files Browse the repository at this point in the history
Bug 1995043: Two storage systems got created while creating one from UI
  • Loading branch information
openshift-merge-robot committed Aug 20, 2021
2 parents 95e91dc + 98e90a3 commit 60df46d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 25 deletions.
Expand Up @@ -20,7 +20,7 @@ const CreateStorageSystem: React.FC<CreateStorageSystemProps> = ({ match }) => {
StorageSystemModel,
);

const { url, params } = match;
const { url } = match;

let wizardSteps: WizardStep[] = [];
let hasOCS: boolean = false;
Expand Down Expand Up @@ -60,7 +60,6 @@ const CreateStorageSystem: React.FC<CreateStorageSystemProps> = ({ match }) => {
hasOCS={hasOCS}
dispatch={dispatch}
disableNext={!ssLoaded || !!ssLoadError}
appName={params.appName}
/>
}
cancelButtonText={t('ceph-storage-plugin~Cancel')}
Expand Down
Expand Up @@ -10,9 +10,8 @@ import {
Alert,
AlertActionCloseButton,
} from '@patternfly/react-core';
import { k8sCreate, K8sKind, referenceForModel } from '@console/internal/module/k8s';
import { k8sCreate, K8sKind } from '@console/internal/module/k8s';
import { history } from '@console/internal/components/utils';
import { ClusterServiceVersionModel } from '@console/operator-lifecycle-manager/src';
import { WizardCommonProps, WizardState } from './reducer';
import {
createNoobaaPayload,
Expand All @@ -27,14 +26,14 @@ import {
StepsName,
StorageClusterSystemName,
} from '../../constants/create-storage-system';
import { OCSServiceModel, StorageSystemModel } from '../../models';
import { OCSServiceModel } from '../../models';
import './create-storage-system.scss';
import {
getExternalStorage,
getStorageSystemKind,
createExternalSSName,
} from '../../utils/create-storage-system';
import { CEPH_STORAGE_NAMESPACE, MINIMUM_NODES } from '../../constants';
import { MINIMUM_NODES } from '../../constants';
import { NetworkType } from '../../types';
import { labelOCSNamespace } from '../ocs-install/ocs-request-data';

Expand Down Expand Up @@ -141,12 +140,7 @@ const getPayloads = (stepName: string, state: WizardState, hasOCS: boolean, t: T
return !_.isEmpty(secondParam) && payloads;
}
if (type === BackingStorageType.EXISTING || type === BackingStorageType.LOCAL_DEVICES) {
const { apiGroup, apiVersion, kind } = OCSServiceModel;
const systemKind = getStorageSystemKind({ apiGroup, apiVersion, kind });
return [
createStorageClusterPayload(state),
createSSPayload(systemKind, StorageClusterSystemName),
];
return [createStorageClusterPayload(state)];
}
}

Expand All @@ -158,7 +152,6 @@ export const CreateStorageSystemFooter: React.FC<CreateStorageSystemFooterProps>
state,
disableNext,
hasOCS,
appName,
}) => {
const { t } = useTranslation();
const { activeStep, onNext, onBack } = React.useContext<WizardContextType>(WizardContext);
Expand Down Expand Up @@ -192,13 +185,7 @@ export const CreateStorageSystemFooter: React.FC<CreateStorageSystemFooterProps>
const requests = payloads.map(({ model, payload }) => k8sCreate(model as K8sKind, payload));
await Promise.all([labelOCSNamespace(), ...requests]);
handleStepId();
stepName === StepsName(t)[Steps.ReviewAndCreate]
? history.push(
`/k8s/ns/${CEPH_STORAGE_NAMESPACE}/${referenceForModel(
ClusterServiceVersionModel,
)}/${appName}/${referenceForModel(StorageSystemModel)}`,
)
: onNext();
stepName === StepsName(t)[Steps.ReviewAndCreate] ? history.push('/odf/systems') : onNext();
} catch (err) {
setRequestError(err.message);
setShowErrorAlert(true);
Expand Down Expand Up @@ -255,5 +242,4 @@ export const CreateStorageSystemFooter: React.FC<CreateStorageSystemFooterProps>
type CreateStorageSystemFooterProps = WizardCommonProps & {
disableNext: boolean;
hasOCS: boolean;
appName: string;
};
Expand Up @@ -8,7 +8,6 @@ import { getOCSRequestData } from '../ocs-install/ocs-request-data';
import { capacityAndNodesValidate } from '../../utils/create-storage-system';
import { ValidationType } from '../../utils/common-ocs-install-el';
import { cephStorageLabel } from '../../selectors';
import { StorageClusterSystemName } from '../../constants/create-storage-system';

export const createSSPayload = (systemKind: string, systemName: string): Payload => {
const { apiGroup, apiVersion, kind, plural } = StorageSystemModel;
Expand Down Expand Up @@ -91,7 +90,6 @@ export const createStorageClusterPayload = (state: WizardState): Payload => {
null,
null,
pvCount,
StorageClusterSystemName,
);
return {
model: {
Expand Down
Expand Up @@ -133,7 +133,6 @@ export const getOCSRequestData = (
selectedArbiterZone?: string,
stretchClusterChecked?: boolean,
availablePvsCount?: number,
name?: string,
): StorageClusterKind => {
const scName: string = storageClass.name;
const isNoProvisioner: boolean = storageClass?.provisioner === NO_PROVISIONER;
Expand All @@ -149,7 +148,7 @@ export const getOCSRequestData = (
apiVersion: 'ocs.openshift.io/v1',
kind: 'StorageCluster',
metadata: {
name: name || OCS_INTERNAL_CR_NAME,
name: OCS_INTERNAL_CR_NAME,
namespace: CEPH_STORAGE_NAMESPACE,
},
spec: {
Expand Down

0 comments on commit 60df46d

Please sign in to comment.