fix(glue): report ErrorMessage on workflow graph Crawl entries (#9204)

Carry FinishedCrawl.errorMessage through WorkflowCrawl and include ErrorMessage on CrawlerDetails.Crawls entries in the workflow run graph when present.

Follow-up to #9195.
This commit is contained in:
Vũ Thế Huy authored and GitHub committed 2026-11-22 09:38:01 -04:00
1 parent 84cbee7d6f
commit fe95e22866
4 files changed
+45 -8

No files matched your search

@@ -231,7 +231,8 @@ public class GlueCrawlerRunService {
}
/** A crawl of a workflow run as the workflow graph reports it: the {@code Crawl} structure. */
public record WorkflowCrawl(String crawlerName, String state, Instant startedOn, Instant completedOn) {}
public record WorkflowCrawl(String crawlerName, String state, Instant startedOn, Instant completedOn,
String errorMessage) {}
/** The crawls, settled, that belong to a workflow run: finished ones and a crawl still running. */
public synchronized List<WorkflowCrawl> crawlsInWorkflowRun(String workflowRunId) {
@@ -239,13 +240,14 @@ public class GlueCrawlerRunService {
for (CrawlerRunRecord stored : recordStore.scan(key -> true)) {
CrawlerRunRecord record = settledRecord(stored.getCrawlerName());
if (record.getCurrentStart() != null && workflowRunId.equals(record.getCurrentWorkflowRunId())) {
running.add(new WorkflowCrawl(record.getCrawlerName(), STATE_RUNNING, record.getCurrentStart(), null));
running.add(new WorkflowCrawl(record.getCrawlerName(), STATE_RUNNING, record.getCurrentStart(), null,
null));
}
}
List<WorkflowCrawl> crawls = new ArrayList<>();
for (FinishedCrawl crawl : workflowCrawlStore.get(workflowRunId).orElse(List.of())) {
crawls.add(new WorkflowCrawl(crawl.getCrawlerName(), crawl.getStatus(), crawl.getStartedAt(),
crawl.getFinishedAt()));
crawl.getFinishedAt(), crawl.getErrorMessage()));
}
crawls.addAll(running);
crawls.sort(Comparator.comparing(WorkflowCrawl::startedOn));
@@ -618,6 +618,9 @@ public class GlueTriggerService {
if (crawl.completedOn() != null) {
entry.put("CompletedOn", EpochSeconds.fromInstant(crawl.completedOn()));
}
if (crawl.errorMessage() != null) {
entry.put("ErrorMessage", crawl.errorMessage());
}
entry.put("LogGroup", "/aws-glue/crawlers");
entry.put("LogStream", name);
crawlList.add(entry);
@@ -107,6 +107,7 @@ class GlueCrawlerRunServiceTest {
assertEquals("FAILED", lastCrawl.getStatus());
assertEquals("backend exploded", lastCrawl.getErrorMessage());
assertEquals("FAILED", service.crawlsInWorkflowRun("wfr_1").get(0).state());
assertEquals("backend exploded", service.crawlsInWorkflowRun("wfr_1").get(0).errorMessage());
service.startCrawler("raw");
assertEquals(2, calls.get());
}
@@ -38,6 +38,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -90,9 +91,13 @@ class GlueWorkflowServiceTest {
}
private void useDurations(int jobSeconds, int crawlSeconds) {
useDurations(jobSeconds, crawlSeconds, CrawlRunner.NO_DATA_STORE);
}
private void useDurations(int jobSeconds, int crawlSeconds, CrawlRunner crawlRunner) {
jobRuns = new GlueJobRunService(new InMemoryStorage<>(), new InMemoryStorage<>(), glueService, jobSeconds, clock);
crawls = new GlueCrawlerRunService(new InMemoryStorage<>(), new InMemoryStorage<>(), glueService, crawlSeconds,
clock);
clock, crawlRunner);
workflows = new GlueTriggerService(new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
glueService, jobRuns, crawls, GlueTriggerService.MAX_TRACKED_CHAINS, clock);
}
@@ -388,9 +393,7 @@ class GlueWorkflowServiceTest {
@SuppressWarnings("unchecked")
private static List<String> jobRunIdsOnNode(WorkflowRun run, String jobName) {
Map<String, Object> node = ((List<Map<String, Object>>) run.getGraph().get("Nodes")).stream()
.filter(n -> "JOB".equals(n.get("Type")) && jobName.equals(n.get("Name")))
.findFirst().orElseThrow();
Map<String, Object> node = graphNode(run.getGraph(), "JOB", jobName);
return ((List<JobRun>) ((Map<String, Object>) node.get("JobDetails")).get("JobRuns")).stream()
.map(JobRun::getId).toList();
}
@@ -617,11 +620,39 @@ class GlueWorkflowServiceTest {
assertEquals("COMPLETED", workflows.getWorkflowRun("etl", runId, false).getStatus());
}
@Test
void workflowGraphCrawlEntryReportsErrorMessageOnlyWhenTheCrawlFailed() {
List<CrawlOutcome> outcomes = List.of(CrawlOutcome.failed("Connection missing not found."), CrawlOutcome.succeeded());
int[] next = {0};
useDurations(0, 0, name -> outcomes.get(next[0]++));
createWorkflow("etl", null, null);
onDemand("start", "etl", startCrawler("raw"));
String failedRunId = workflows.startWorkflowRun("etl", null);
Map<String, Object> failedCrawl = crawlsOnNode(workflows.getWorkflowRun("etl", failedRunId, true), "raw").getFirst();
assertEquals("FAILED", failedCrawl.get("State"));
assertEquals("Connection missing not found.", failedCrawl.get("ErrorMessage"));
String succeededRunId = workflows.startWorkflowRun("etl", null);
Map<String, Object> succeededCrawl = crawlsOnNode(workflows.getWorkflowRun("etl", succeededRunId, true), "raw").getFirst();
assertEquals("SUCCEEDED", succeededCrawl.get("State"));
assertFalse(succeededCrawl.containsKey("ErrorMessage"));
}
@SuppressWarnings("unchecked")
private static List<Map<String, Object>> crawlsOnNode(WorkflowRun run, String crawlerName) {
Map<String, Object> node = graphNode(run.getGraph(), "CRAWLER", crawlerName);
return (List<Map<String, Object>>) ((Map<String, Object>) node.get("CrawlerDetails")).get("Crawls");
}
private static String nodeId(Map<String, Object> graph, String type, String name) {
return (String) graphNode(graph, type, name).get("UniqueId");
}
@SuppressWarnings("unchecked")
private static Map<String, Object> graphNode(Map<String, Object> graph, String type, String name) {
return ((List<Map<String, Object>>) graph.get("Nodes")).stream()
.filter(node -> type.equals(node.get("Type")) && name.equals(node.get("Name")))
.map(node -> (String) node.get("UniqueId"))
.findFirst().orElseThrow();
}
}