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 1995043: Two storage systems got created while creating one from UI #9836

Merged
merged 1 commit into from Aug 20, 2021
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 @@ -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();
afreen23 marked this conversation as resolved.
Show resolved Hide resolved
} 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