Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WX-1110[risk=low] Added endpoint to fetch failed tasks by workflow id #7165

Merged
merged 18 commits into from
Jul 17, 2023

Conversation

JVThomas
Copy link
Contributor

@JVThomas JVThomas commented Jun 23, 2023

Addresses WX-1110

PR adds a new endpoint to fetch failed tasks on a workflow via workflow id. For tasks that execute with a scatter and/or multiple attempts this means that the latest attempt and/or latest scatter index with a Failed status will be returned. No workflow/sub-workflow specific data (outside of the root workflow id) is returned in the response in an attempt to keep the payload light.

Aspects of note: JDBC driver handles SerialClob and query syntax differently between PostgreSQL and non-PostgreSQL databases. As a result the query used is formatted differently to fit the DB specific expectations.

Response is built using the already existing logic contained in MetadataBuilderActor (though new event listeners were added for the new endpoint flow).

Food for thought (and for documentation purposes): I discovered that currently existing JDBC behavior adds SerialClob objects in the pg_largeobject table and supplies the OID as the value in METADATA_ENTRY.METADATA_VALUE. Considering the number of key-value pairs on the metadata json response I'm curious about capacity concerns.

@JVThomas JVThomas marked this pull request as ready for review July 11, 2023 13:19
@JVThomas JVThomas requested a review from a team as a code owner July 11, 2023 13:19
Copy link
Contributor

@jgainerdewar jgainerdewar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job!!! Left a few questions about tests but I think this looks great.

val resultSetColumnNames = s"me.${workflowUuid}, me.${callFqn}, me.${scatterIndex}, me.${retryAttempt}, me.${metadataKey}, me.${metadataValue}, me.${metadataValueType}, me.${metadataTimestamp}, me.${metadataJournalId}"

val query = sql"""
SELECT #${resultSetColumnNames}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up with these hash signs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's Slick's way of handling string interpolation. You would think "Why not use ${}? It's because Slick is using that notation specifically to bind values in a query.

So something like tableName.colName = ${val} would work, but `SELECT ${tableName}.${colName} would throw an error since you're declaring an identifier rather than providing a value.

This also caught me off guard and is only briefly covered in the Slick docs.

'/api/workflows/{version}/{id}/metadata/failed-jobs':
get:
operationId: failed-jobs
summary: Get call-level metadata of failed tasks for a specified workflow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work for subworkflows as well? If not this should probably say "root workflow."

Copy link
Contributor Author

@JVThomas JVThomas Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point (only works for root workflows). I'll update the description

@@ -95,6 +100,7 @@ class MetadataBuilderActorSpec extends TestKitSuite with AsyncFlatSpecLike with
// We'll use a Query instead of a SingleWorkflowMetadataGet, so we expect the WorkflowID this time:
val expectedRes =
s"""{
|"${workflowA}": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change represent a real change in behavior, or just a change in the structure of the test?

Copy link
Contributor Author

@JVThomas JVThomas Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this comment. TLDR: I updated the wrong test.

Copy link
Contributor

@jgainerdewar jgainerdewar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this needs a pre-merge merge from develop, but LGTM!

Copy link
Contributor

@THWiseman THWiseman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice job figuring out the slick stuff, some nasty surprises in there.

@JVThomas JVThomas merged commit af9660e into develop Jul 17, 2023
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants