Skip to content

Add a POST /nodes/{name}/validate/ endpoint for revalidating already existing nodes by name#619

Merged
samredai merged 1 commit intoDataJunction:mainfrom
samredai:revalidate
Jul 12, 2023
Merged

Add a POST /nodes/{name}/validate/ endpoint for revalidating already existing nodes by name#619
samredai merged 1 commit intoDataJunction:mainfrom
samredai:revalidate

Conversation

@samredai
Copy link
Copy Markdown
Contributor

@samredai samredai commented Jul 11, 2023

Summary

Currently DJ attempts to validate nodes as any live change is being made to the system. When things are missed or preconditions are fulfilled after the fact, this PR provides a mechanism to request the server to revalidate an existing node, requiring that you simply provide the node name. Over time, we should catch these scenarios more and more so that system status is more accurately captured in realtime and revalidation is never required.

Here's a video example of how this was added to the UI. I manually set nodes in the metadata that I knew to be valid as invalid, and clicking the icon revalidated them and updated the status. If they were invalid, the status icon would have stayed as a red x.

revalidate.mov

Test Plan

docker compose --profile demo up and tested it in the UI. Also tested curl commands directly to the dj server.

Deployment Plan

@netlify
Copy link
Copy Markdown

netlify bot commented Jul 11, 2023

Deploy Preview for thriving-cassata-78ae72 canceled.

Name Link
🔨 Latest commit cb25a72
🔍 Latest deploy log https://app.netlify.com/sites/thriving-cassata-78ae72/deploys/64ade7da82790000086bbe75

@samredai samredai changed the title Add /nodes/{name}/validate/ endpoint for revalidating already existing nodes by name Add a POST /nodes/{name}/validate/ endpoint for revalidating already existing nodes by name Jul 11, 2023
@samredai samredai marked this pull request as ready for review July 11, 2023 21:13
Copy link
Copy Markdown
Collaborator

@shangyian shangyian left a comment

Choose a reason for hiding this comment

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

Looks useful!

Once we've ironed out all the bugs, do you think we'll still want this endpoint though?

Copy link
Copy Markdown
Member

@agorajek agorajek left a comment

Choose a reason for hiding this comment

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

Agree with @shangyian in that I think this endpoint should be internal only. Meaning if a user ever need to use it then we have a bigger problem that should be addressed.

2 questions in-line.

node = get_node_by_name(session, name)
current_node_revision = node.current
if current_node_revision.type == NodeType.SOURCE:
current_node_revision.status = NodeStatus.VALID
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is dangerous, if the source node does not match the underlying table anymore. Right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right, I hadn't considered that reflection could be setting a source node as invalid. Good catch!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@agorajek thinking about this a bit more, since we're going to leave this as an admin endpoint, is it valuable to leave this here as an escape hatch for when a reflection service is acting up?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes agree.

else:
status = NodeStatus.VALID

current_node_revision.status = status
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if current_node_revision.status already equals to status. Would we need to create a new revision?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This doesn't create a new revision, it just updates the system status value on the existing revision. But good point that there's no reason to even do a db commit at all so I'll fix this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to check if current_node_revision.status != status:

@samredai
Copy link
Copy Markdown
Contributor Author

samredai commented Jul 11, 2023

Makes sense! I'll update this PR to remove the UI changes then and we can just call the endpoint when needed.

EDIT: Done

Copy link
Copy Markdown
Member

@agorajek agorajek left a comment

Choose a reason for hiding this comment

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

Looks good.

@samredai samredai merged commit 8214d6d into DataJunction:main Jul 12, 2023
youngman-droid pushed a commit to youngman-droid/dj that referenced this pull request Aug 26, 2023
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