mirror of
https://github.com/nestriness/nestri.git
synced 2026-11-03 22:22:39 +02:00
api: accept the host's own tier label in a report
The report schema pinned each box's tier to our size enum, but hosts name a box's shape by resolution (1080p). Every report naming a box was a 400, so stop reasons never reached the run. Placement already stores the size; the reported label is free text and is not stored.
This commit is contained in:
@@ -75,7 +75,7 @@ describe('POST /machine/report', () => {
|
||||
boxesKnown: 2,
|
||||
boxesRunning: 1,
|
||||
boxes: [
|
||||
{ boxId: running.id, tier: 'sm', state: 'running', pid: 1234, uptimeS: 45 },
|
||||
{ boxId: running.id, tier: '1080p', state: 'running', pid: 1234, uptimeS: 45 },
|
||||
{ boxId: idle.id, tier: 'sm', state: 'created' }
|
||||
]
|
||||
});
|
||||
|
||||
@@ -235,22 +235,32 @@ export namespace Box {
|
||||
* kept and already trustworthy. Storing a plausible number instead of a
|
||||
* measured one is how a scheduler learns to trust a field nobody produced.
|
||||
*/
|
||||
/**
|
||||
* The host's own name for a box's shape, such as `1080p`.
|
||||
*
|
||||
* Free text, and never stored: placement already wrote this box's size on
|
||||
* its row. Pinning it to our size enum turned every report from a host
|
||||
* that names shapes by resolution into a 400, and with it every stop
|
||||
* reason the report carries.
|
||||
*/
|
||||
const ReportedTier = z.string();
|
||||
|
||||
export const Reported = z.discriminatedUnion('state', [
|
||||
z.object({
|
||||
boxId: z.string(),
|
||||
tier: z.enum(BoxTier.enumValues),
|
||||
tier: ReportedTier,
|
||||
state: z.literal('created')
|
||||
}),
|
||||
z.object({
|
||||
boxId: z.string(),
|
||||
tier: z.enum(BoxTier.enumValues),
|
||||
tier: ReportedTier,
|
||||
state: z.literal('running'),
|
||||
pid: z.number().int().optional(),
|
||||
uptimeS: z.number().int()
|
||||
}),
|
||||
z.object({
|
||||
boxId: z.string(),
|
||||
tier: z.enum(BoxTier.enumValues),
|
||||
tier: ReportedTier,
|
||||
state: z.literal('stopped'),
|
||||
reason: z.string(),
|
||||
clean: z.boolean()
|
||||
|
||||
Reference in New Issue
Block a user