Skip to content

Commit 007dc2b

Browse files
committed
refactor(webapp): match template results to presets by (cpu, memory_gb) content
1 parent a3c3595 commit 007dc2b

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

apps/webapp/app/v3/services/computeTemplateCreation.server.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ export class ComputeTemplateCreationService {
230230
// or the request itself failed. Optional preset failures are logged and
231231
// do not contribute to the message. Returns undefined on success.
232232
//
233-
// Result-to-preset matching is by index: response.results[i] corresponds
234-
// to this.presets[i]. While the multi-config compute path is being built
235-
// out, the gateway may return fewer entries than presets requested - any
236-
// unbuilt required preset is still treated as a failure.
233+
// Result-to-preset matching is by (cpu, memory_gb) content. Compute may
234+
// return fewer entries than presets requested (multi-config path being
235+
// built out, or dedup of equivalent configs) - any unbuilt required preset
236+
// is still treated as a failure.
237237
private failureMessageForRequiredMode(
238238
outcome: CreateTemplateOutcome,
239239
deploymentFriendlyId: string,
@@ -245,9 +245,13 @@ export class ComputeTemplateCreationService {
245245

246246
const failures: string[] = [];
247247

248-
this.presets.forEach((preset, i) => {
248+
this.presets.forEach((preset) => {
249249
const isRequired = this.requiredPresets.has(preset.name);
250-
const result = outcome.results[i];
250+
const result = outcome.results.find(
251+
(r) =>
252+
Math.abs(r.machine_config.cpu - preset.cpu) < 1e-9 &&
253+
Math.abs(r.machine_config.memory_gb - preset.memory_gb) < 1e-9
254+
);
251255

252256
if (!result) {
253257
if (isRequired) {

0 commit comments

Comments
 (0)