Skip to content

Commit

Permalink
Merge pull request #1536 from avivtur/fix-default-boot-source
Browse files Browse the repository at this point in the history
CNV-32874: Customize VM is prompting 'No boot source available' dialog
  • Loading branch information
openshift-merge-robot authored Sep 17, 2023
2 parents e56f2ea + cde1626 commit 3d7f545
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { SelectSourceUploadPVCProgress } from './SelectSourceUploadPVCProgress';
import {
appendDockerPrefix,
getContainerDiskSource,
getDefaultSourceStorage,
getGenericSourceCustomization,
getPVCSource,
} from './utils';
Expand Down Expand Up @@ -81,6 +82,7 @@ export const SelectSource: React.FC<SelectSourceProps> = ({
React.useEffect(() => {
switch (selectedSourceType) {
case DEFAULT_SOURCE:
return onSourceChange(getDefaultSourceStorage(volumeQuantity));
case BLANK_SOURCE_NAME:
case UPLOAD_SOURCE_NAME:
return onSourceChange(
Expand Down
10 changes: 10 additions & 0 deletions src/views/catalog/customize/components/CustomizeSource/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ export const getSourceTypeFromDiskSource = (
return DEFAULT_SOURCE;
};

export const getDefaultSourceStorage = (storage: string): V1beta1DataVolumeSpec => ({
storage: {
resources: {
requests: {
storage,
},
},
},
});

export const getGenericSourceCustomization = (
diskSourceId: SOURCE_OPTIONS_IDS,
url?: string,
Expand Down
12 changes: 10 additions & 2 deletions src/views/catalog/customize/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,16 @@ export const overrideVirtualMachineDataVolumeSpec = (
): V1VirtualMachine => {
return produceVMDisks(virtualMachine, (draftVM) => {
const dataVolumeTemplate = draftVM.spec.dataVolumeTemplates[0];
if (dataVolumeTemplate && Boolean(customSource)) {
draftVM.spec.dataVolumeTemplates[0].spec = customSource;
if (dataVolumeTemplate && !isEmpty(customSource)) {
const { storage, ...restSpec } = customSource;

if (!isEmpty(storage)) {
if (!isEmpty(restSpec)) {
draftVM.spec.dataVolumeTemplates[0].spec = customSource;
} else {
draftVM.spec.dataVolumeTemplates[0].spec.storage = storage;
}
}

const shouldAddImmediateBind = customSource?.source?.blank || customSource?.source?.upload;

Expand Down

0 comments on commit 3d7f545

Please sign in to comment.