Skip to content

Commit

Permalink
Bug 1870339: Sets volumeMode as block for RBD+RWX
Browse files Browse the repository at this point in the history
Signed-off-by: Kanika Murarka <kmurarka@redhat.com>
  • Loading branch information
Kanika Murarka committed Sep 23, 2020
1 parent cafc1d1 commit c076b57
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import * as _ from 'lodash';

import { Form, FormGroup, Grid, GridItem, TextInput } from '@patternfly/react-core';
import {
Expand Down Expand Up @@ -33,7 +34,10 @@ import {
} from '@console/internal/models';
import { getName, getNamespace, Status } from '@console/shared';
import { StorageClassDropdown } from '@console/internal/components/utils/storage-class-dropdown';
import { dropdownUnits } from '@console/internal/components/storage/shared';
import {
dropdownUnits,
cephRBDProvisionerSuffix,
} from '@console/internal/components/storage/shared';
import { useK8sGet } from '@console/internal/components/utils/k8s-get-hook';

import './restore-pvc-modal.scss';
Expand Down Expand Up @@ -108,6 +112,18 @@ const RestorePVCModal = withHandlePromise<RestorePVCModalProps>(
},
};

if (pvcResource) {
// should set block only for RBD + RWX
if (
_.endsWith(snapshotClassResource?.driver, cephRBDProvisionerSuffix) &&
accessModes.includes('ReadWriteMany')
) {
restorePVCTemplate.spec.volumeMode = 'Block';
} else {
restorePVCTemplate.spec.volumeMode = pvcResource?.spec?.volumeMode;
}
}

// eslint-disable-next-line promise/catch-or-return
handlePromise(
k8sCreate(PersistentVolumeClaimModel, restorePVCTemplate, namespace),
Expand Down Expand Up @@ -212,6 +228,7 @@ const RestorePVCModal = withHandlePromise<RestorePVCModalProps>(
</div>
</ModalBody>
<ModalSubmitFooter
submitDisabled={!pvcSC}
inProgress={inProgress}
errorMessage={errorMessage}
submitText="Restore"
Expand Down

0 comments on commit c076b57

Please sign in to comment.