fix(gpu-service): avoid stringifying unset cpu in the instance form
`${values.spec?.resources?.cpu}` turned an unset cpu into the literal
string "undefined", which fails k8s quantity validation. Omit cpu when
it has no value instead.
This commit is contained in:
@@ -260,11 +260,16 @@ const GPUServiceInstanceForm: React.FC<InstanceFormProps> = forwardRef(
|
||||
const cpuNum = unitResourcesParsed?.cpu?.num;
|
||||
const ramNum = unitResourcesParsed?.ram?.num;
|
||||
|
||||
const fallbackCpu = values.spec?.resources?.cpu;
|
||||
return {
|
||||
cpu:
|
||||
accelerator > 0 && cpuNum
|
||||
? `${accelerator * cpuNum}${unitResourcesParsed?.cpu?.unit || ''}`
|
||||
: `${values.spec?.resources?.cpu}`,
|
||||
: // Don't stringify an unset value — `${undefined}` becomes the
|
||||
// literal "undefined", which fails k8s quantity validation.
|
||||
fallbackCpu != null && fallbackCpu !== ''
|
||||
? `${fallbackCpu}`
|
||||
: undefined,
|
||||
ram:
|
||||
accelerator > 0 && ramNum
|
||||
? `${accelerator * ramNum}${unitResourcesParsed?.ram?.unit || ''}`
|
||||
|
||||
Reference in New Issue
Block a user