Skip to content

Commit

Permalink
Merge pull request #2294 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…2273-to-release-4.17

[release-4.17] CNV-49651: put a default disk size if user have no access to the pvcs
  • Loading branch information
openshift-merge-bot[bot] authored Dec 2, 2024
2 parents 9bdb973 + 77ff168 commit d4d3f53
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { FC } from 'react';

import { useInstanceTypeVMStore } from '@catalog/CreateFromInstanceTypes/state/useInstanceTypeVMStore';
import CapacityInput from '@kubevirt-utils/components/CapacityInput/CapacityInput';
import { DEFAULT_DISK_SIZE } from '@kubevirt-utils/components/DiskModal/utils/constants';
import { getVolumeSnapshotSize } from '@kubevirt-utils/resources/bootableresources/selectors';
import { convertToBaseValue, humanizeBinaryBytes } from '@kubevirt-utils/utils/humanize.js';

Expand All @@ -12,9 +13,7 @@ const DiskSize: FC = () => {

const pvcDiskSize =
pvcSource?.spec?.resources?.requests?.storage || getVolumeSnapshotSize(volumeSnapshotSource);
const sizeData = humanizeBinaryBytes(convertToBaseValue(pvcDiskSize)).string;

if (!pvcDiskSize) return null;
const sizeData = humanizeBinaryBytes(convertToBaseValue(pvcDiskSize || DEFAULT_DISK_SIZE)).string;

return <CapacityInput onChange={setCustomDiskSize} size={customDiskSize || sizeData} />;
};
Expand Down
7 changes: 6 additions & 1 deletion src/views/catalog/CreateFromInstanceTypes/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
CloudInitUserData,
convertUserDataObjectToYAML,
} from '@kubevirt-utils/components/CloudinitModal/utils/cloudinit-utils';
import { DEFAULT_DISK_SIZE } from '@kubevirt-utils/components/DiskModal/utils/constants';
import { InterfaceTypes } from '@kubevirt-utils/components/DiskModal/utils/types';
import { addSecretToVM } from '@kubevirt-utils/components/SSHSecretModal/utils/utils';
import { sysprepDisk, sysprepVolume } from '@kubevirt-utils/components/SysprepModal/sysprep-utils';
Expand Down Expand Up @@ -144,7 +145,11 @@ export const generateVM = (
storage: pvcSource?.spec?.resources?.requests?.storage,
},
}
: {},
: {
requests: {
storage: DEFAULT_DISK_SIZE,
},
},
storageClassName,
},
},
Expand Down

0 comments on commit d4d3f53

Please sign in to comment.