fix(striker-ui): correct response status when no records in fetch anvil cpu

main
Tsu-ba-me 1 year ago
parent ac28ea88df
commit bf19d03ee5
  1. 9
      striker-ui-api/src/lib/request_handlers/anvil/getAnvilCpu.ts

@ -1,4 +1,3 @@
import assert from 'assert';
import { RequestHandler } from 'express'; import { RequestHandler } from 'express';
import { query } from '../../accessModule'; import { query } from '../../accessModule';
@ -49,14 +48,14 @@ export const getAnvilCpu: RequestHandler<AnvilDetailParamsDictionary> = async (
c.scan_hardware_cpu_threads c.scan_hardware_cpu_threads
ORDER BY b.host_name;`, ORDER BY b.host_name;`,
); );
assert.ok(rCpus.length, 'No entry found');
} catch (error) { } catch (error) {
stderr(`Failed to get anvil ${anvilUuid} cpu info; CAUSE: ${error}`); stderr(`Failed to get anvil ${anvilUuid} cpu info; CAUSE: ${error}`);
return response.status(500).send(); return response.status(500).send();
} }
if (!rCpus.length) return response.status(404).send();
let rAllocatedRow: [cpuAllocated: string][]; let rAllocatedRow: [cpuAllocated: string][];
try { try {
@ -74,14 +73,14 @@ export const getAnvilCpu: RequestHandler<AnvilDetailParamsDictionary> = async (
ON a.server_uuid = b.server_definition_server_uuid ON a.server_uuid = b.server_definition_server_uuid
WHERE a.server_anvil_uuid = '${anvilUuid}';`, WHERE a.server_anvil_uuid = '${anvilUuid}';`,
); );
assert.ok(rAllocatedRow.length, 'No entry found');
} catch (error) { } catch (error) {
stderr(`Failed to get anvil ${anvilUuid} server cpu info; CAUSE: ${error}`); stderr(`Failed to get anvil ${anvilUuid} server cpu info; CAUSE: ${error}`);
return response.status(500).send(); return response.status(500).send();
} }
if (!rAllocatedRow.length) return response.status(404).send();
const { const {
0: { 5: rMinCores, 6: rMinThreads }, 0: { 5: rMinCores, 6: rMinThreads },
} = rCpus; } = rCpus;

Loading…
Cancel
Save