-
Notifications
You must be signed in to change notification settings - Fork 534
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
[Bug][Dora-Cahnge_lead_time_calculator] incorrect linking of commits to deployments when using azuredevops and webhook #7193
Comments
Hi @wouldd , I'm trying to understand what you have encountered. Correct me if I'm wrong:
|
@Startrekzky pretty much. 1) yes usig azure devops go plugin which is what is pulling commits/pr information. and using teh 'webhook' to post deployment information that includes the shas of the commits being deployed. |
I suspect that the Currently, both azuredevops plugins are using For Change Lead Time to be calculated correctly, the following requirements must be met:
loop in @mr-ks |
@klesh that certainly sounds plausible. I'm trying to wrap my head around your point 1 about all deployment commits forming a linear history 'newer deployment commit should contain all older deployment commits' I'm not sure I understand why that would be desired?
So you would process a deployment row, link it's deployment commits and join to their commit records and pr record. then calculate the various time deltas for commit->pr create->pr-merge->deployment to production and record that cycle tyime against those commits. |
@wouldd It is needed to determine which deployment a PR belongs to. If I understand your assumption correctly, you are connecting the PR to deployment by commit dates? no, it won't work, because the deployment happened after a commit got committed not necessarily including the commit. For example, one may start committing to a feature branch for the next version while a deployment on the release branch for the current version is taking place. |
@klesh I don't think we need to relate things by date at all. So between these you can link all the data required to caluclate cycle time. you know exactly which commits where in a deployment and can look up which PR those commits were associated with to reference those timings and look up what date that commit was originally made to calculate how long it took from that point to the point it was deployed. Why would a deployment commit be linked to all previous deployment commits? |
No, this is not the case. The webhook, or any other data sources would have only 1 commit sha for each repo per deployment stored in the Let's assume that you have a Sorry, I shouldn't use the term
That is the idea but not the whole story, in fact,
Let me know if I missed anything. |
@klesh Sorry for the slow response, I was on vacation for the last two weeks then getting ontop of other work stuff. unfortunately as it stands this makes the dora metrics unusable for us, and those would be the main thing we're interested in. |
I might be encountering the same bug. If not, please feel free to delete this comment as I don't want to stray the discussion. I created a project with a single Github repo, using the GitHub connection for commits and PRs. A webhook is used for deployments. This is also visible in the I'm on 1.0.0b4. Here's the sanitized CURL for the webhook:
Thanks! |
@Startrekzky I'm curious about the characterisation of the bug priority you set being 'does not affect the functionality or isn't evident' from my point of view this renders one of the core dora metrics unusable. I would consider that to be a very evident impact on function and a key metric we would be interested in. |
Thank you for pointing this out, @wouldd . I mis-operated it. It's updated now. |
Was the deployment the earliest one? If so, it is expected. |
I think the core of the problem is that the time ranges of deployments and PRs are not aligned.
|
@klesh the first option here is a complete non-starter. we have >1000 repos which in some cases have existed for over 10 years. we have no way to recreate the deployment history and no reason to do so. we're not intereested in looking back that far at metrics. I think this would be common to most real-world users, they won't be starting out with devlake in place, they will be adding it to probably quite mature teams with long histories which are incomplete. the system needs to be able to handle picking up from a postiion of only being told about new deployments even though there is a long commit history already. I would say that the dora metrics needs to be restrcted to starting at the earliest commit that any deployment webhook call has explicitly linked to a deployment. This is why I though the sql in the linking logic query was simply wrong in my initial bug description. I would assume @nicolavolpini is in a similar boat since those numbers showed 6 month lead times. |
This is precisely the situation we are in. In our case, we had to rely on Webhooks for deployments since our pipeline structure - although it uses Jenkins - makes it impossible to correlate Jenkins deployment SHAs to GitHub PR SHAs (we have an intermediate step where Jenkins is picking artifacts from a central repo, thus a different SHA is shown in the job). On a side note: what I expected was for a deployment webhook to be bound only to the PR it relates to. |
Hi @nicolavolpini and @wouldd , @klesh and I have reached an agreement on the solution to this issue, which is This solution will fix the issue you have faced. The con is that the very first deployment will not be linked to any PRs. So, there might be a very small number of PR's cycle time that can not be matched, but I think it's acceptable. Does it make sense? |
Hello @Startrekzky , thanks that would be a good compromise for me. Better than the wrong data for sure. |
@Startrekzky @nicolavolpini @klesh I agree with Nicola that it's certainly better than the current situation and would soon become irrelevant in the stats. so if that's the easiest route then i'm all for it. |
Hi @wouldd , do you mean that even though we can't link all PRs merged (e.g. PR-1, PR-2, PR-3. PR-3 is the one that linked to the merge_commit that triggers deploy-1) between the |
@wouldd I don't think it's entirely avoidable, but I agree that your proposal could associate the first deployment (pushed to DevLake) with ONE of the PRs merged between the first deployment and its prior deployment. We link deployments to PR via the medium 'newly-added-commits-by-d1', but we don't know all of these commits, we only know the merge commit sha and what you were trying to propose was to find the PR of the merge commit sha. If your use case is to trigger a deployment every time a PR gets merged, it will work, because every deployment only gets one PR deployed. However, not all users use this practice. For those who do not, d1 will only be linked to part of the PRs, and this is the cons I said. I hope it makes sense. |
Already effective in v1.0.0-beta6. @nicolavolpini @wouldd |
Hi @nicolavolpini , is this the first deployment webhook you posted via webhook? Did this deployment deploy all the commits merged by those associated PRs? If so, the logic might be correct. Also, please mention me when commenting, otherwise I won't be notified. |
Search before asking
What happened
I assume that the issue I'm seeing is somehow unique to me using the azuredevops_go plugin and the webhook for reporting deployments from octopus. However the 'bug' I've identified looks to me like it would effect everyone. So probably the real issue is somewhere else but all I can say is that for me the DORA metrics are all wildly out because it relates every commit that has ever been made against a repo to the most recent deploy. This means the cycle time calculation for each commit is showing as just the age of that commit until the most recent deploy.
I believe the offending line is this one: https://github.com/apache/incubator-devlake/blob/cb69f35b5319f57dd3d6c8534121a6ca069cd175/backend/plugins/dora/tasks/change_lead_time_calculator.go#L215C2-L215C3
the commits_diffs table has 3 columns, commit_sha, old_commit_sha and new_commit_sha. For me I need the filter in this query to filter where the mergeSha = cd.new_commit_sha in order to work correctly.
I've tested this in my setup and that change has the expected behaviour. However, I would obviously expect this to be broken for everyone doing DORA metrics at all, and it seems unlikely no one else noticed this. So I guess maybe the intention of that commits_diffs table is to have information in it differently and perhaps the azure plugin is populating it incorrectly?
What do you expect to happen
In my case I have lots of quite old 4+years minimum repos. but I've only just started feeding deploy events in. so I would expect only to have data for the relatively few new commits since this went into place. and I would expect the cycle time calculations for those to be right.
How to reproduce
configure a long standing repo with lots of historical commtis against it. create a webhook call for the most recent commit/commtis in teh repo and expect to see dora calculations for those commits only. However you should see that it links all of the old commits to the new deployment.
Indeed when I run with a version in which I changed the above filter check then I get the behavior I expect. all the numbers make sense and the pr_cycle_time calculations show up numbers for only commits that have been reported as part of deployments
Anything else
Happens every time for all commits.
Version
master
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: