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

[release-4.16] Bug 2317793: Block creation of external mode when Provider mode is already present #1641

Open
wants to merge 1 commit into
base: release-4.16
Choose a base branch
from
Open
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 @@ -3,6 +3,7 @@ import {
STORAGE_CLUSTER_SYSTEM_KIND,
NO_PROVISIONER,
} from '@odf/core/constants';
import { PROVIDER_MODE } from '@odf/core/features';
import { useSafeK8sGet } from '@odf/core/hooks';
import { useODFNamespaceSelector } from '@odf/core/redux';
import { scResource } from '@odf/core/resources';
Expand All @@ -25,6 +26,7 @@ import {
} from '@odf/shared/types';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import { isDefaultClass, getODFCsv, getGVKLabel } from '@odf/shared/utils';
import { useFlag } from '@openshift-console/dynamic-plugin-sdk';
import * as _ from 'lodash-es';
import {
Form,
Expand Down Expand Up @@ -213,6 +215,7 @@ export const BackingStorage: React.FC<BackingStorageProps> = ({

const isFullDeployment = deployment === DeploymentType.FULL;
const isProviderMode = deployment === DeploymentType.PROVIDER_MODE;
const isProviderModePresent = useFlag(PROVIDER_MODE) && hasInternal;
const isNonRHCSExternalType =
type === BackingStorageType.EXTERNAL &&
externalStorage !== OCSStorageClusterModel.kind;
Expand Down Expand Up @@ -269,7 +272,7 @@ export const BackingStorage: React.FC<BackingStorageProps> = ({
* Allow pre selecting the "external connection" option instead of the "existing" option
* if an OCS Storage System is already created.
*/
if (hasOCS && allowedExternalStorage.length) {
if (hasOCS && allowedExternalStorage.length && !isProviderModePresent) {
dispatch({
type: 'backingStorage/setType',
payload: BackingStorageType.EXTERNAL,
Expand All @@ -282,7 +285,7 @@ export const BackingStorage: React.FC<BackingStorageProps> = ({
},
});
}
}, [dispatch, allowedExternalStorage.length, hasOCS]);
}, [dispatch, allowedExternalStorage.length, hasOCS, isProviderModePresent]);

React.useEffect(() => {
/*
Expand Down Expand Up @@ -384,7 +387,11 @@ export const BackingStorage: React.FC<BackingStorageProps> = ({
value={BackingStorageType.EXTERNAL}
isChecked={type === BackingStorageType.EXTERNAL}
onChange={(event, _unused) => onRadioSelect(_unused, event)}
isDisabled={allowedExternalStorage.length === 0 || isProviderMode}
isDisabled={
allowedExternalStorage.length === 0 ||
isProviderMode ||
isProviderModePresent
}
body={
showExternalStorageSelection && (
<ExternalSystemSelection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { FDF_FLAG } from '@odf/core/redux';
import { DeploymentType } from '@odf/core/types';
import { BackingStorageType, DeploymentType } from '@odf/core/types';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import { useFlag } from '@openshift-console/dynamic-plugin-sdk';
import {
Expand Down Expand Up @@ -49,6 +49,12 @@ export const SelectDeployment: React.FC<SelectDeploymentProps> = ({
// 'value' on SelectProps['onSelect'] is string hence does not match with payload of type "DeploymentType"
payload: value as DeploymentType,
});
if (value === DeploymentType.PROVIDER_MODE) {
dispatch({
type: 'backingStorage/setType',
payload: BackingStorageType.EXISTING,
});
}
setIsSelectOpen(false);
};

Expand Down
Loading