Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const CPUTopologyHelperText: FC<CPUTopologyHelperTextProps> = ({ cpu }) => {
const { t } = useKubevirtTranslation();
const { cores, sockets, threads } = cpu || {};

const totalCPU = cores * sockets * threads;
// VMs migrated from vSphere may not have spec.template.spec.domain.cpu.threads set
const totalCPU = cores * sockets * (threads || 1);

return (
<div className="cpu-topology-helper-text">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const getUpdatedCPU = (cpu: V1CPU, newValue: number, fieldChanged: CPUCom
};

export const convertTopologyToVCPUs = (cpu: V1CPU): number =>
cpu?.cores * cpu?.sockets * cpu?.threads;
// VMs migrated from vSphere may not have spec.template.spec.domain.cpu.threads set
cpu?.cores * cpu?.sockets * (cpu?.threads || 1);

export const formatVCPUsAsSockets = (cpu: V1CPU): V1CPU => {
const numVCPUs = convertTopologyToVCPUs(cpu);
Expand Down
4 changes: 3 additions & 1 deletion src/utils/resources/template/utils/flavor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export const parseCPU = (cpu: V1CPU): V1CPU => {
*/
export const vCPUCount = (cpu: V1CPU): number => {
const parsedCpu = parseCPU(cpu);
return parsedCpu.sockets * parsedCpu.cores * parsedCpu.threads;

// VMs migrated from vSphere may not have spec.template.spec.domain.cpu.threads set
return parsedCpu.sockets * parsedCpu.cores * (parsedCpu.threads || 1);
};

/**
Expand Down