fix(striker-ui-api): handle null server host uuid in build power handler

main
Tsu-ba-me 9 months ago
parent 9ed047d3a7
commit 245e3a94cf
  1. 13
      striker-ui-api/src/lib/request_handlers/command/buildPowerHandler.ts

@ -179,11 +179,16 @@ export const buildServerPowerHandler: (
let serverHostUuid: string | undefined; let serverHostUuid: string | undefined;
try { try {
// When the server host uuid is null, fall back to the first subnode of
// the node that owns the server.
const rows = await query<[[null | string]]>( const rows = await query<[[null | string]]>(
`SELECT server_host_uuid `SELECT
FROM servers COALESCE(a.server_host_uuid, b.anvil_node1_host_uuid)
WHERE server_uuid = '${uuid}' FROM servers AS a
AND server_state != '${DELETED}';`, LEFT JOIN anvils AS b
ON a.server_anvil_uuid = b.anvil_uuid
WHERE server_state != '${DELETED}'
AND server_uuid = '${uuid}';`,
); );
assert.ok(rows.length, `No entry found`); assert.ok(rows.length, `No entry found`);

Loading…
Cancel
Save