feat(gpu-service): align instance-type/flavor contract with status.detail API

- spec keeps definition fields only; observed hardware read from status.detail
- sliceable derived from slicedDetail (logical count / physical profiles)
- flat snapshot format isolated in instance-description for back-compat
- drop flavor.spec.sliceable; onceMaxRequest realigned (no ram/localStorage)
- lock compute ratio to memory ratio when coresPercentageOvercommit is false
- sliced mode submits whole cores / Gi; displayName-first type labels
This commit is contained in:
jialin
2026-07-22 15:52:17 +08:00
parent cbd9fc4946
commit fe4dbf087f
21 changed files with 433 additions and 494 deletions
@@ -1,5 +1,25 @@
import _ from 'lodash';
import { InstanceTypeItem } from '../config/types';
import { isSliceableDetail } from '../config';
import { InstanceTypeItem, InstanceTypeSnapshotSpec } from '../config/types';
// Build the flat snapshot spec from a live (API-shaped) instance type:
// definition fields from spec, observed hardware from status.detail, plus the
// derived `sliceable`. This flat shape is the UI document format persisted in
// the instance's `description` (older instances already carry it flat) and
// doubles as the display model of the type card / metadata section.
export const buildInstanceTypeSnapshotSpec = (
instanceType: InstanceTypeItem
): InstanceTypeSnapshotSpec => {
const detail = instanceType.status?.detail;
return {
...instanceType.spec,
..._.pick(detail, ['manufacturer', 'product', 'family', 'memory']),
sliceable: isSliceableDetail(detail?.slicedDetail),
// Accelerator CPU identity only — the full CPU descriptor is too bulky to
// persist and the UI only shows who made it.
cpu: _.pick(detail?.cpu, ['manufacturer', 'product', 'family'])
};
};
// Serialize the chosen instance type into the instance's `description` field —
// a persisted spec snapshot the form reads back to render the type card and
@@ -10,9 +30,6 @@ export const saveInstanceDataInDescription = (
): string => {
return JSON.stringify({
name: instanceType.name,
spec: {
..._.omit(instanceType.spec, ['cache', 'cpu']),
cpu: _.pick(instanceType.spec?.cpu, ['manufacturer', 'product', 'family'])
}
spec: buildInstanceTypeSnapshotSpec(instanceType)
});
};