Skip to content

Commit

Permalink
Added logic to fail all steps involved in an upload in case the uploa…
Browse files Browse the repository at this point in the history
…d fails
  • Loading branch information
Gonzalo Avalos Ribas authored and Gonzalo Avalos Ribas committed Oct 9, 2023
1 parent 4f9eaaf commit 753c85c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/integration-sdk-runtime/src/execution/dependencyGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ export function executeStepDependencyGraph<
if (createStepGraphObjectDataUploader) {
uploader = createStepGraphObjectDataUploader(lastStepId);
}
const stepsInvolvedInUpload = graphObjectStore.getStepsStored
? graphObjectStore.getStepsStored()
: [];
await graphObjectStore.flush(
async (entities) =>
entities.length
Expand All @@ -476,12 +479,13 @@ export function executeStepDependencyGraph<
name: IntegrationErrorEventName.UnexpectedError,
description: 'Upload to persister failed',
});

executionContext.logger.stepFailure(
workingGraph.getNodeData(lastStepId),
err,
);
stepResultsMap[lastStepId] = StepResultStatus.FAILURE;
for (const stepId of stepsInvolvedInUpload) {
executionContext.logger.stepFailure(
workingGraph.getNodeData(stepId),
err,
);
stepResultsMap[stepId] = StepResultStatus.FAILURE;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ export class FileSystemGraphObjectStore implements GraphObjectStore {
integrationStepsToGraphObjectIndexMetadataMap(params.integrationSteps);
}
}
getStepsStored() {
return this.localGraphObjectStore.getStepsStored();
}

async addEntities(
stepId: string,
Expand Down
18 changes: 18 additions & 0 deletions packages/integration-sdk-runtime/src/storage/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,22 @@ export class InMemoryGraphObjectStore implements GraphObjectStore {
0,
);
}

getStepsStored(): string[] {
const stepIds: string[] = [];

for (const graphObjectData of this.relationshipKeyToRelationshipMap.values()) {
const { stepId } = graphObjectData;
if (!stepIds.includes(stepId)) {
stepIds.push(stepId);
}
}
for (const graphObjectData of this.entityKeyToEntityMap.values()) {
const { stepId } = graphObjectData;
if (!stepIds.includes(stepId)) {
stepIds.push(stepId);
}
}
return stepIds;
}
}

0 comments on commit 753c85c

Please sign in to comment.