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

CNV-33739: Reduce the default disk size of CDROM to 10GiB #1588

Merged
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
1 change: 1 addition & 0 deletions src/utils/components/DiskModal/state/initialState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { diskTypes } from '@kubevirt-utils/resources/vm/utils/disk/constants';
import { interfaceTypes, sourceTypes } from '../DiskFormFields/utils/constants';

export const DEFAULT_DISK_SIZE = '30Gi';
export const DEFAULT_CDROM_DISK_SIZE = '10Gi';

export type DiskFormState = {
accessMode: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { SecretModel, V1Template } from '@kubevirt-ui/kubevirt-api/console';
import VirtualMachineModel from '@kubevirt-ui/kubevirt-api/console/models/VirtualMachineModel';
import { V1beta1DataVolumeSpec, V1ContainerDiskSource } from '@kubevirt-ui/kubevirt-api/kubevirt';
import { updateCloudInitRHELSubscription } from '@kubevirt-utils/components/CloudinitModal/utils/cloudinit-utils';
import {
DEFAULT_CDROM_DISK_SIZE,
DEFAULT_DISK_SIZE,
} from '@kubevirt-utils/components/DiskModal/state/initialState';
import {
addSecretToVM,
applyCloudDriveCloudInitVolume,
Expand Down Expand Up @@ -156,12 +160,13 @@ export const useCustomizeFormSubmit = ({
const diskUploadDV = getUploadDataVolume(
dataVolumeTemplate?.metadata?.name,
updatedVM.metadata.namespace,
diskSource?.storage?.resources?.requests?.storage || '30Gi',
diskSource?.storage?.resources?.requests?.storage || DEFAULT_DISK_SIZE,
);
const cdUploadDV = getUploadDataVolume(
`${updatedVM?.metadata?.name}-${INSTALLATION_CDROM_NAME}`,
updatedVM.metadata.namespace,
(cdSource as V1beta1DataVolumeSpec)?.storage?.resources?.requests?.storage || '30Gi',
(cdSource as V1beta1DataVolumeSpec)?.storage?.resources?.requests?.storage ||
DEFAULT_CDROM_DISK_SIZE,
);

await Promise.all(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import * as React from 'react';
import React, { FC, useCallback } from 'react';

import { V1Template } from '@kubevirt-ui/kubevirt-api/console';
import { V1beta1DataVolumeSpec, V1ContainerDiskSource } from '@kubevirt-ui/kubevirt-api/kubevirt';
import {
DEFAULT_CDROM_DISK_SIZE,
DEFAULT_DISK_SIZE,
} from '@kubevirt-utils/components/DiskModal/state/initialState';
import { DataUpload } from '@kubevirt-utils/hooks/useCDIUpload/useCDIUpload';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import { getTemplateImportURLs } from '@kubevirt-utils/resources/template';
Expand Down Expand Up @@ -42,7 +46,7 @@ export type CustomizeSourceProps = {
withDrivers: boolean;
};

export const CustomizeSource: React.FC<CustomizeSourceProps> = ({
export const CustomizeSource: FC<CustomizeSourceProps> = ({
cdSource,
cdUpload,
diskSource,
Expand All @@ -55,7 +59,7 @@ export const CustomizeSource: React.FC<CustomizeSourceProps> = ({
withDrivers,
}) => {
const { t } = useKubevirtTranslation();
const onCDCheckboxChange = React.useCallback(() => {
const onCDCheckboxChange = useCallback(() => {
if (cdSource) {
setCDSource(undefined);
} else {
Expand All @@ -72,25 +76,28 @@ export const CustomizeSource: React.FC<CustomizeSourceProps> = ({
<BootCDCheckbox cdSource={cdSource} onChange={onCDCheckboxChange} />

{cdSource && (
<SelectSource
sourceOptions={[
HTTP_SOURCE_NAME,
PVC_SOURCE_NAME,
CONTAINER_DISK_SOURCE_NAME,
UPLOAD_SOURCE_NAME,
]}
data-test-id="cd-boot-source"
httpSourceHelperURL={httpSourceHelperURL}
onSourceChange={setCDSource}
registrySourceHelperText={registrySourceHelperText}
relevantUpload={cdUpload}
selectedSource={cdSource}
sourceLabel={t('CD source')}
sourcePopOver={<SelectCDSourcePopOver />}
/>
<>
<SelectSource
sourceOptions={[
HTTP_SOURCE_NAME,
PVC_SOURCE_NAME,
CONTAINER_DISK_SOURCE_NAME,
UPLOAD_SOURCE_NAME,
]}
data-test-id="cd-boot-source"
httpSourceHelperURL={httpSourceHelperURL}
initialVolumeQuantity={DEFAULT_CDROM_DISK_SIZE}
onSourceChange={setCDSource}
registrySourceHelperText={registrySourceHelperText}
relevantUpload={cdUpload}
selectedSource={cdSource}
sourceLabel={t('CD source')}
sourcePopOver={<SelectCDSourcePopOver />}
/>
<Divider className="divider" />
</>
)}

{cdSource && <Divider className="divider" />}
<SelectSource
sourceOptions={
isBootSourceAvailable
Expand All @@ -113,7 +120,7 @@ export const CustomizeSource: React.FC<CustomizeSourceProps> = ({
data-test-id="disk-boot-source"
defaultsAsBlank={Boolean(cdSource)}
httpSourceHelperURL={httpSourceHelperURL}
initialVolumeQuantity={getTemplateStorageQuantity(template) || '30Gi'}
initialVolumeQuantity={getTemplateStorageQuantity(template) || DEFAULT_DISK_SIZE}
onSourceChange={setDiskSource}
registrySourceHelperText={registrySourceHelperText}
relevantUpload={diskUpload}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import * as React from 'react';
import React, {
FC,
JSXElementConstructor,
ReactElement,
ReactNode,
useEffect,
useState,
} from 'react';
import { Controller, useFormContext } from 'react-hook-form';

import { V1beta1DataVolumeSpec, V1ContainerDiskSource } from '@kubevirt-ui/kubevirt-api/kubevirt';
import CapacityInput from '@kubevirt-utils/components/CapacityInput/CapacityInput';
import { DEFAULT_DISK_SIZE } from '@kubevirt-utils/components/DiskModal/state/initialState';
import { FormTextInput } from '@kubevirt-utils/components/FormTextInput/FormTextInput';
import { DataUpload } from '@kubevirt-utils/hooks/useCDIUpload/useCDIUpload';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
Expand Down Expand Up @@ -40,17 +48,17 @@ export type SelectSourceProps = {
registrySourceHelperText?: string;
relevantUpload?: DataUpload;
selectedSource?: V1beta1DataVolumeSpec | V1ContainerDiskSource;
sourceLabel: React.ReactNode | string;
sourceLabel: ReactNode | string;
sourceOptions: SOURCE_OPTIONS_IDS[];
sourcePopOver?: React.ReactElement<any, React.JSXElementConstructor<any> | string>;
sourcePopOver?: ReactElement<any, JSXElementConstructor<any> | string>;
withSize?: boolean;
};

export const SelectSource: React.FC<SelectSourceProps> = ({
export const SelectSource: FC<SelectSourceProps> = ({
'data-test-id': testId,
defaultsAsBlank,
httpSourceHelperURL,
initialVolumeQuantity = '30Gi',
initialVolumeQuantity = DEFAULT_DISK_SIZE,
onSourceChange,
registrySourceHelperText,
relevantUpload,
Expand All @@ -69,17 +77,17 @@ export const SelectSource: React.FC<SelectSourceProps> = ({
const httpURL = watch(`${testId}-httpURL`);
const containerImage = watch(`${testId}-containerImage`);

const [volumeQuantity, setVolumeQuantity] = React.useState(initialVolumeQuantity);
const [volumeQuantity, setVolumeQuantity] = useState(initialVolumeQuantity);

const [selectedSourceType, setSourceType] = React.useState<SOURCE_OPTIONS_IDS>(sourceOptions[0]);
const [pvcNameSelected, selectPVCName] = React.useState<string>();
const [pvcNamespaceSelected, selectPVCNamespace] = React.useState<string>();
const [selectedSourceType, setSourceType] = useState<SOURCE_OPTIONS_IDS>(sourceOptions[0]);
const [pvcNameSelected, selectPVCName] = useState<string>();
const [pvcNamespaceSelected, selectPVCNamespace] = useState<string>();
const showSizeInput =
withSize ||
selectedSourceType === HTTP_SOURCE_NAME ||
selectedSourceType === UPLOAD_SOURCE_NAME;

React.useEffect(() => {
useEffect(() => {
switch (selectedSourceType) {
case DEFAULT_SOURCE:
return onSourceChange(getDefaultSourceStorage(volumeQuantity));
Expand Down Expand Up @@ -120,7 +128,7 @@ export const SelectSource: React.FC<SelectSourceProps> = ({
showSizeInput,
]);

React.useEffect(() => {
useEffect(() => {
if (defaultsAsBlank) {
setSourceType(BLANK_SOURCE_NAME);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { TFunction } from 'react-i18next';

import { V1Template } from '@kubevirt-ui/kubevirt-api/console';
import { V1beta1DataVolumeSpec, V1ContainerDiskSource } from '@kubevirt-ui/kubevirt-api/kubevirt';
import { DEFAULT_DISK_SIZE } from '@kubevirt-utils/components/DiskModal/state/initialState';
import {
getTemplateContainerDisks,
getTemplateVirtualMachineObject,
Expand Down Expand Up @@ -52,7 +53,7 @@ export const getGenericSourceCustomization = (
storage: {
resources: {
requests: {
storage: storage ?? '30Gi',
storage: storage ?? DEFAULT_DISK_SIZE,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import React, { FC } from 'react';
import { useForm } from 'react-hook-form';
import { useHistory } from 'react-router-dom';

import { DataSourceModelRef } from '@kubevirt-ui/kubevirt-api/console/models/DataSourceModel';
import { DEFAULT_DISK_SIZE } from '@kubevirt-utils/components/DiskModal/state/initialState';
import MutedTextSpan from '@kubevirt-utils/components/MutedTextSpan/MutedTextSpan';
import TabModal from '@kubevirt-utils/components/TabModal/TabModal';
import { DEFAULT_NAMESPACE } from '@kubevirt-utils/constants/constants';
Expand All @@ -26,7 +27,7 @@ type CreateDataSourceModalProps = {
onClose: () => void;
};

export const CreateDataSourceModal: React.FC<CreateDataSourceModalProps> = ({
export const CreateDataSourceModal: FC<CreateDataSourceModalProps> = ({
isOpen,
namespace,
onClose,
Expand All @@ -44,7 +45,7 @@ export const CreateDataSourceModal: React.FC<CreateDataSourceModalProps> = ({
defaultValues: {
importsToKeep: 3,
name: generateDataSourceName(),
size: '30Gi',
size: DEFAULT_DISK_SIZE,
},
});
const importsToKeep = watch('importsToKeep');
Expand Down
9 changes: 5 additions & 4 deletions src/views/templates/actions/components/SelectSource.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import React, { FC, ReactNode } from 'react';

import { V1beta1DataVolumeSpec } from '@kubevirt-ui/kubevirt-api/kubevirt';
import CapacityInput from '@kubevirt-utils/components/CapacityInput/CapacityInput';
import { DEFAULT_DISK_SIZE } from '@kubevirt-utils/components/DiskModal/state/initialState';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import { FormGroup, TextInput, ValidatedOptions } from '@patternfly/react-core';

Expand All @@ -20,14 +21,14 @@ type SelectSourceProps = {
initialVolumeQuantity?: string;
onSourceChange: (customSource: V1beta1DataVolumeSpec) => void;
source: V1beta1DataVolumeSpec;
sourceLabel: React.ReactNode;
sourceLabel: ReactNode;
sourceOptions: SOURCE_OPTIONS_IDS[];
withSize?: boolean;
};

export const SelectSource: React.FC<SelectSourceProps> = ({
export const SelectSource: FC<SelectSourceProps> = ({
httpSourceHelperText,
initialVolumeQuantity = '30Gi',
initialVolumeQuantity = DEFAULT_DISK_SIZE,
onSourceChange,
source,
sourceLabel,
Expand Down
3 changes: 2 additions & 1 deletion src/views/templates/actions/components/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { V1beta1DataSource } from '@kubevirt-ui/kubevirt-api/containerized-data-importer/models';
import { V1beta1DataVolumeSpec } from '@kubevirt-ui/kubevirt-api/kubevirt';
import { DEFAULT_DISK_SIZE } from '@kubevirt-utils/components/DiskModal/state/initialState';

import { SOURCE_OPTIONS_IDS, SOURCE_TYPES } from '../../utils/constants';
import { getDataSourceDataVolume } from '../editBootSource';
Expand Down Expand Up @@ -35,7 +36,7 @@ export const getGenericSourceCustomization = (
storage: {
resources: {
requests: {
storage: storage ?? '30Gi',
storage: storage ?? DEFAULT_DISK_SIZE,
},
},
},
Expand Down
Loading