Skip to content

Commit

Permalink
Label namespace during storage cluster creation
Browse files Browse the repository at this point in the history
  • Loading branch information
bipuladh committed Dec 10, 2020
1 parent 8e93bbc commit 87d55c4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import FileUpload from './fileUpload';
import { isValidJSON, checkError, prettifyJSON, getIPFamily } from './utils';
import { OCS_INDEPENDENT_FLAG, OCS_FLAG, OCS_CONVERGED_FLAG } from '../../features';
import { OCS_EXTERNAL_CR_NAME, IP_FAMILY } from '../../constants';
import { labelOCSNamespace } from '../ocs-install/ocs-request-data';
import './install.scss';

const CreateExternalCluster = withHandlePromise((props: CreateExternalClusterProps) => {
Expand Down Expand Up @@ -123,7 +124,11 @@ const CreateExternalCluster = withHandlePromise((props: CreateExternalClusterPro
};

handlePromise(
Promise.all([k8sCreate(SecretModel, secret), k8sCreate(OCSServiceModel, ocsObj)]),
Promise.all([
labelOCSNamespace(),
k8sCreate(SecretModel, secret),
k8sCreate(OCSServiceModel, ocsObj),
]),
(data) => {
dispatch(setFlag(OCS_INDEPENDENT_FLAG, true));
dispatch(setFlag(OCS_CONVERGED_FLAG, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { StorageAndNodes } from './wizard-pages/storage-and-nodes-step';
import '../attached-devices.scss';
import { getName } from '@console/shared';
import { StorageClusterKind } from '../../../../types';
import { getOCSRequestData, labelNodes } from '../../ocs-request-data';
import { getOCSRequestData, labelNodes, labelOCSNamespace } from '../../ocs-request-data';
import { OCSServiceModel } from '../../../../models';
import { OCS_CONVERGED_FLAG, OCS_INDEPENDENT_FLAG, OCS_FLAG } from '../../../../features';
import { ReviewAndCreate } from './wizard-pages/review-and-create-step';
Expand Down Expand Up @@ -263,7 +263,7 @@ const CreateSC: React.FC<CreateSCProps> = ({ match, hasNoProvSC, mode, lsoNs })
selectedArbiterZone,
stretchClusterChecked,
);
const promises: Promise<K8sResourceKind>[] = [...labelNodes(nodes)];
const promises: Promise<K8sResourceKind>[] = [...labelNodes(nodes), labelOCSNamespace()];
if (encryption.advanced && kms.hasHandled) {
promises.push(...createKmsResources(kms));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const makeOCSRequest = (
isEncrypted: boolean,
isMinimal: boolean,
): Promise<any> => {
const promises = labelNodes(selectedNodes);
const promises: Promise<K8sResourceKind>[] = [...labelNodes(selectedNodes)];
const ocsObj = getOCSRequestData(
storageClass,
defaultRequestSize.BAREMETAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import { OCSServiceModel } from '../../../models';
import { OCS_CONVERGED_FLAG, OCS_INDEPENDENT_FLAG, OCS_FLAG } from '../../../features';
import { OCS_INTERNAL_CR_NAME, MINIMUM_NODES, CreateStepsSC } from '../../../constants';
import { StorageClusterKind } from '../../../types';
import { labelNodes, getOCSRequestData } from '../ocs-request-data';
import { labelNodes, getOCSRequestData, labelOCSNamespace } from '../ocs-request-data';
import { SelectCapacityAndNodes, Configure, ReviewAndCreate } from './install-wizard-steps';
import { initialState, reducer, InternalClusterState } from './reducer';
import '../install-wizard/install-wizard.scss';
import { createKmsResources } from '../../kms-config/utils';
import { NetworkType } from '../types';
import '../install-wizard/install-wizard.scss';

const makeOCSRequest = (state: InternalClusterState): Promise<StorageClusterKind> => {
const {
Expand All @@ -49,7 +49,7 @@ const makeOCSRequest = (state: InternalClusterState): Promise<StorageClusterKind
clusterNetwork,
kms.hasHandled && encryption.advanced,
);
const promises: Promise<K8sResourceKind>[] = [...labelNodes(nodes)];
const promises: Promise<K8sResourceKind>[] = [...labelNodes(nodes), labelOCSNamespace()];
if (encryption.advanced && kms.hasHandled) {
promises.push(...createKmsResources(kms));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as _ from 'lodash';
import { k8sPatch, NodeKind, StorageClassResourceKind } from '@console/internal/module/k8s';
import { NodeModel } from '@console/internal/models';
import {
k8sPatch,
NodeKind,
StorageClassResourceKind,
K8sKind,
} from '@console/internal/module/k8s';
import { NodeModel, NamespaceModel } from '@console/internal/models';
import {
NO_PROVISIONER,
OCS_INTERNAL_CR_NAME,
Expand Down Expand Up @@ -71,6 +76,21 @@ export const labelNodes = (selectedNodes: NodeKind[]): Promise<NodeKind>[] => {
);
};

export const labelOCSNamespace = (): Promise<K8sKind> =>
k8sPatch(
NamespaceModel,
{
metadata: {
name: CEPH_STORAGE_NAMESPACE,
},
},
{
op: 'add',
path: '/metadata/labels',
value: { 'openshift.io/cluster-monitoring': 'true' },
},
);

export const createDeviceSet = (
scName: string,
osdSize: string,
Expand Down

0 comments on commit 87d55c4

Please sign in to comment.