-
Notifications
You must be signed in to change notification settings - Fork 98
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
Webhook for deployments #562
Comments
@jayantbh working on this. |
Sure. Do share your approach before you begin implementation. |
Important This issue is tagged |
@jayantbh Currently we take PR Merge or Workflow ( like Github_Actions ) for deployments. correct? I am thinking to create a route that collects workflow/deployment webhook data. This is basic idea, although more brainstorming needed. |
This should ideally happen on the python backend (apiserver dir). But yes, you have the right idea. I'll let @adnanhashmi09 explain further. |
Keep the following in mind while implementing the workflow:
{
"workflow_runs":[
{
"workflow_name":"custom_workflow",
"repo_names":["middleware"],
"event_actor":"adnanhashmi09",
"head_branch":"master",
"workflow_run_unique_id":"unique_item",
"status":"SUCCESS",
"duration":"200", // can be provided, or we can infer this
"workflow_run_conducted_at":"2024-09-28T20:35:45.123456+00:00"
}
]
} Read through the workflow sync once to check all the fields required for creating a RepoWorkflowRun
So there are a lot of moving parts in this implementation and would require a thorough understanding of our system. Please read through the sync and document your approach here before starting to implement. This is a rather comprehensive task and would longer to implement. |
@adnanhashmi09 Providers like Github actions, Gitlab, Circleci... are the sources of user deployment data. What other platforms can send data to our system? The structure of data will be different for each source, so we will need adapter to process data or user will be sending the structured response? We can store all the incoming data into redis which will be later picked up for processing. We can only verify errors like API_Key before sending the response as data is not yet processed but we need to return 200 asap. So how we agree on point 6 as we are not processing data synchronously? We also fetch data from Github Actions REST Api. So both rest api and webhook data will be stored in same table, right? Can a user also prune data fetched from Github Actions REST Api (point 7) ? Can you please elaborate point 11 ? |
This webhook implementation is platform agnostic. We don't care about the workflow providers as the provider is not responsible for sending data. It is the user who integrates our webhook into their workflow who is responsible for sending the correct data. We will define a set of fields we require in the request body for us to register RepoWorkflow and RepoWorkflowRuns. It is up to the end user to make sure correct values are being sent.
Well, we can check for a few errors besides API_KEY errors. For instance, Maximum allowed data to be sent in once request, validate if the repo_names sent are linked with middleware or not. These operations are fairly quick to compute.
I don't think anybody would get github actions data from both integration and webhook. But yes, in practice we keep both data. We don't give the option to prune github actions data as they can always unlink that integration.
We can save the entire request data in a database table including the data we receive for processing. This way we can check for errors and show alerts to the user by getting data from that table. It can also serve as a data dump to check what data has been received by our system for processing. |
@adnanhashmi09 The ?? is I have doubt whether to add it or not. API KEYS
// APIKeys Table Schema in Postgres
API_KEYS {
keyname: "",
secret_key: "",
expiry_at: "",
is_deleted: "",
scope: "" // [ WORKFLOW, INCIDENT ]
org_id: "" // ??
} Receiving Webhook DataThe "/webhook" api will be added to flask server. {
event_type: "WORKFLOW", // or "INCIDENT",
payload: {
workflow_runs: [{
workflow_name: "name",
provider_workflow_id: "", // ??
repo_name: "middleware",
event_actor: "githubusername",
head_branch: "master",
workflow_run_id: "",
status: "SUCCESS",
duration: "200",
workflow_run_conducted_at: "date",
html_url: "url"
}]
}
}
// Headers: "X-Secret-Key": "secret_key" Pre Processing Validation
Store the data for processing
WebhookEventRequests {
request_type: "DEPLOYMENT", // Or INCIDENT
request_data: "{ workflow_runs: [] }",
status: "",
error: "",
created_in_db_at: "",
processed_at: "date",
response_data: "",
retries: 0
}
UIThere will be 3 pages namely: Deployments, Incidents, API Keys. Discussion
|
Why do we need this ?
Currently PR merges are assumed to be deployments for a repo, which is fair for any repo that runs on some kind of a CI.
But for many such repos that don't, we should at least support a webhook based mechanism that allows me to feed my deployment/workflow runs data into Middleware.
That will let me have a better picture of my Dora metrics with more accurate Lead Time, and Deployment Frequency.
The text was updated successfully, but these errors were encountered: