feat(gpu-service): allow re-typing stopped instances on edit

- Add instance-type column to edit drawer for stopped instances
- Extract saveInstanceDataInDescription into shared util
- Floor sliced unit resources; keep CPU >= 1 core
- Expose applyInstanceType for both create and edit flows
This commit is contained in:
jialin
2026-07-22 15:52:17 +08:00
parent e9d585cc90
commit 96d194a4f4
6 changed files with 215 additions and 150 deletions
@@ -0,0 +1,18 @@
import _ from 'lodash';
import { InstanceTypeItem } from '../config/types';
// 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
// derive unit resources. Shared by the create/recreate flow (card selection)
// and the edit flow (change-type overlay).
export const saveInstanceDataInDescription = (
instanceType: InstanceTypeItem
): string => {
return JSON.stringify({
name: instanceType.name,
spec: {
..._.omit(instanceType.spec, ['cache', 'cpu']),
cpu: _.pick(instanceType.spec?.cpu, ['manufacturer', 'product', 'family'])
}
});
};