Skip to content
This repository was archived by the owner on Apr 28, 2020. It is now read-only.

Commit 886de62

Browse files
suomiymareklibra
authored andcommitted
take storageClassConfigMap into account when creating disk patches (#555)
Signed-off-by: suomiy <[email protected]>
1 parent 094354b commit 886de62

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

src/k8s/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './request';
2+
export * from './requests/storageClass';
23
export * from './selectors';
34

45
export { getBootableDevicesInOrder } from './vmBuilder';

src/utils/patches.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import { get, has, findIndex } from 'lodash';
22

3-
import { getDisks, getInterfaces, getName, getDescription, getFlavor, getCpu, getMemory } from '../selectors';
3+
import {
4+
getDisks,
5+
getInterfaces,
6+
getName,
7+
getDescription,
8+
getFlavor,
9+
getCpu,
10+
getMemory,
11+
getDefaultSCAccessMode,
12+
getDefaultSCVolumeMode,
13+
} from '../selectors';
414
import { getBootDeviceIndex } from './utils';
515
import {
616
ANNOTATION_FIRST_BOOT,
@@ -9,7 +19,6 @@ import {
919
TEMPLATE_FLAVOR_LABEL,
1020
deviceTypeToPathKey,
1121
DEVICE_TYPE_INTERFACE,
12-
PVC_ACCESSMODE_RWM,
1322
} from '../constants';
1423
import { NETWORK_TYPE_POD } from '../components/Wizard/CreateVmWizard/constants';
1524
import { assignBootOrderIndex, getBootableDevicesInOrder, getDevices, addBindingToInterface } from '../k8s/vmBuilder';
@@ -47,7 +56,7 @@ export const getPxeBootPatch = vm => {
4756
return patches;
4857
};
4958

50-
export const getAddDiskPatch = (vm, storage) => {
59+
export const getAddDiskPatch = (vm, storage, storageClassConfigMap) => {
5160
const disk = {
5261
name: storage.name,
5362
bootOrder: assignBootOrderIndex(vm),
@@ -69,7 +78,8 @@ export const getAddDiskPatch = (vm, storage) => {
6978
},
7079
spec: {
7180
pvc: {
72-
accessModes: [PVC_ACCESSMODE_RWM],
81+
accessModes: [getDefaultSCAccessMode(storageClassConfigMap, storage.storageClass)],
82+
volumeMode: getDefaultSCVolumeMode(storageClassConfigMap, storage.storageClass),
7383
resources: {
7484
requests: {
7585
storage: `${storage.size}Gi`,

src/utils/tests/patches.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
ANNOTATION_FIRST_BOOT,
55
BOOT_ORDER_SECOND,
66
BOOT_ORDER_FIRST,
7-
PVC_ACCESSMODE_RWM,
87
TEMPLATE_FLAVOR_LABEL,
98
POD_NETWORK,
109
DISK_PATH_KEY,
@@ -24,6 +23,7 @@ import {
2423
} from '../patches';
2524
import { cloudInitTestVm } from '../../tests/mocks/vm/cloudInitTestVm.mock';
2625
import { NETWORK_TYPE_POD, NETWORK_TYPE_MULTUS } from '../../components/Wizard/CreateVmWizard/constants';
26+
import { getDefaultSCAccessMode, getDefaultSCVolumeMode } from '../../selectors/configmap';
2727

2828
const getVM = firstBoot => ({
2929
metadata: {
@@ -86,7 +86,8 @@ const dataVolumeTemplate = {
8686
},
8787
spec: {
8888
pvc: {
89-
accessModes: [PVC_ACCESSMODE_RWM],
89+
accessModes: [getDefaultSCAccessMode()],
90+
volumeMode: getDefaultSCVolumeMode(),
9091
resources: {
9192
requests: {
9293
storage: `${storageNoClass.size}Gi`,

0 commit comments

Comments
 (0)