Bug 224514 - [GitHub] Add script to verify integrity of the mirror
Summary: [GitHub] Add script to verify integrity of the mirror
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jonathan Bedard
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-04-13 15:27 PDT by Jonathan Bedard
Modified: 2021-04-14 14:52 PDT (History)
5 users (show)

See Also:


Attachments
Patch (3.22 KB, patch)
2021-04-13 15:31 PDT, Jonathan Bedard
no flags Details | Formatted Diff | Diff
Patch (3.44 KB, patch)
2021-04-14 10:48 PDT, Jonathan Bedard
no flags Details | Formatted Diff | Diff
[fast-cq] patch (3.60 KB, patch)
2021-04-14 11:30 PDT, Jonathan Bedard
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Bedard 2021-04-13 15:27:04 PDT
It's relatively easy to verify if the GitHub mirror is out of sync with Subversion using identifiers. There is a desire to codify this check and run it automatically in infrastructure.
Comment 1 Radar WebKit Bug Importer 2021-04-13 15:27:20 PDT
<rdar://problem/76613576>
Comment 2 Jonathan Bedard 2021-04-13 15:31:18 PDT
Created attachment 425923 [details]
Patch
Comment 3 Aakash Jain 2021-04-13 16:25:58 PDT
Comment on attachment 425923 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=425923&action=review

> Tools/Scripts/check-github-mirror-integrity:39
> +        print(f'Cannonical HEAD commit {canonical_tip} matches mirrored HEAD commit {mirror_tip}')

It might be confusing to users (like me) to clearly understand what exactly "Cannonical" and "mirrored" refer to. Might be better to directly refer to GitHub and svn.webkit.org in all the output messages. Maybe something like this would be better:

print(f'GitHub and svn.webkit.org are in sync.\nHEAD commit on GitHub {canonical_tip} matches HEAD commit on svn.webkit.org {mirror_tip}')

> Tools/Scripts/check-github-mirror-integrity:42
> +    if mirror_tip.identifier == canonical_tip.identifier - 1:

Why is this fine, and in which case do we expect this?

> Tools/Scripts/check-github-mirror-integrity:43
> +        print(f'Cannonical HEAD commit {canonical_tip} slitly ahead of mirrored HEAD commit {mirror_tip}')

Should reverse the message and make it more user-friendly. Something like:
print(f'GitHub repo is slightly behind svn.webkit.org. This is ok.\nHEAD commit on GitHub {canonical_tip} is one behind HEAD commit on svn.webkit.org {mirror_tip}')

> Tools/Scripts/check-github-mirror-integrity:46
> +    print(f'Cannonical HEAD commit {canonical_tip} does not match mirrored HEAD commit {mirror_tip}')

Better to start this message with: "Error: ", so that it's clear to the user that this is an error condition. 
Might as well list the next steps. e.g.: "This indicates a serious issue with the repository, please inform admin@webkit.org urgently."
Comment 4 Jonathan Bedard 2021-04-13 17:30:06 PDT
Comment on attachment 425923 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=425923&action=review

>> Tools/Scripts/check-github-mirror-integrity:42
>> +    if mirror_tip.identifier == canonical_tip.identifier - 1:
> 
> Why is this fine, and in which case do we expect this?

I'm concerned if we don't do this, we'll find ourselves with a common race condition where we are in the process of running the post-commit hook but haven't yet pushed to GitHub.
Comment 5 Aakash Jain 2021-04-14 08:20:14 PDT
Comment on attachment 425923 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=425923&action=review

>> Tools/Scripts/check-github-mirror-integrity:46
>> +    print(f'Cannonical HEAD commit {canonical_tip} does not match mirrored HEAD commit {mirror_tip}')
> 
> Better to start this message with: "Error: ", so that it's clear to the user that this is an error condition. 
> Might as well list the next steps. e.g.: "This indicates a serious issue with the repository, please inform admin@webkit.org urgently."

Also it would be a good idea to print how much behind is github, both, in terms of number of commits and time.
Comment 6 Aakash Jain 2021-04-14 08:24:37 PDT
(In reply to Jonathan Bedard from comment #4)
> I'm concerned if we don't do this, we'll find ourselves with a common race condition where we are in the process of running the post-commit hook but haven't yet pushed to GitHub.
ok, make sense. But it might be a real issue as well, where the syncing is broken and only one commit was made after that.

It would be be a good idea to print the time delta since the first missing commit from github was made, and if that time is higher than the time we expect syncing to take, then we should print an error.
Comment 7 Jonathan Bedard 2021-04-14 10:48:52 PDT
Created attachment 426011 [details]
Patch
Comment 8 Aakash Jain 2021-04-14 11:07:47 PDT
Comment on attachment 426011 [details]
Patch

Doesn't address my comment about adding time based check, and adding further statement to error message like: "This indicates a serious issue with the repository, please inform admin@webkit.org urgently."

But those can be done later as well.
Comment 9 Jonathan Bedard 2021-04-14 11:30:35 PDT
Created attachment 426021 [details]
[fast-cq] patch
Comment 10 EWS 2021-04-14 14:52:19 PDT
Committed r275970 (236523@main): <https://commits.webkit.org/236523@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 426021 [details].