New SystemHook: `repository_update`
Description
We've ported push
and tag_push
from ProjectHook
to SystemHook
as part of the effort to move Geo (#76 (closed)) synchronization code to use System Hooks.
See for documentation and examples: https://docs.gitlab.com/ee/system_hooks/system_hooks.html#push-events
Based on the issue rised by https://gitlab.com/gitlab-org/gitlab-ee/issues/1463, this alternative has some drawbacks from the first implementation:
- A push that contains more than one branch (multiple
/refs
), will trigger multiple notification requestsO(n)
- This adds a lot of additional "useless" network traffic (as we update the repositories with a "fetch all" algorithm)
- This also can cause the issue described by https://gitlab.com/gitlab-org/gitlab-ee/issues/1463 when multiple concurrently updates generates additional garbage to the git repository
We initially thought this would not be an issue as the jobs would eventually resolve themselves, but as https://gitlab.com/gitlab-org/gitlab-ee/issues/1463 showed us wrong, we need to rethink the way we handle the notification.
cc @DouweM @smcgivern @stanhu @dbalexandre @rspeicher
Proposal
My idea is to have back a single notification request for every "user issued git push operation", which means, every new push
event that is handled by GitTagPushService
should trigger a single repository_update
event.
We should not change or remove the existing push
and tag_push
events, but add an additional repository_update
as described above.
As we are not bounded anymore for a specific branch, we should get ride of most of the specific fields both push
and tag_push
events send, and send only the following:
{
"event_name": "repository_update",
"user_id": 4,
"user_name": "John Smith",
"user_email": "john@example.com",
"user_avatar": "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80",
"project_id": 15,
"project":{
"name":"Diaspora",
"description":"",
"web_url":"http://example.com/mike/diaspora",
"avatar_url":null,
"git_ssh_url":"git@example.com:mike/diaspora.git",
"git_http_url":"http://example.com/mike/diaspora.git",
"namespace":"Mike",
"visibility_level":0,
"path_with_namespace":"mike/diaspora",
"default_branch":"master",
"homepage":"http://example.com/mike/diaspora",
"url":"git@example.com:mike/diaspora.git",
"ssh_url":"git@example.com:mike/diaspora.git",
"http_url":"http://example.com/mike/diaspora.git"
},
"changes": [
{
"before": "95790bf891e76fee5e1747ab589903a6a1f80f22",
"after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"ref": "refs/heads/master"
},
...
],
"refs": ["refs/heads/master", "refs/heads/development"],
}
This event type should be made optional (default to false
) and should be made configurable in the System Hooks admin screen as the others.