Skip to content

Commit ca85e25

Browse files
committed
Address Eventual consistency issue with github
1 parent dd4eb7b commit ca85e25

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

conf/appconfig.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@
219219
HOOK_TYPE_CI = 'ci'
220220
HOOK_TYPE_BUILDER = 'builder'
221221
HOOK_TYPE_SCM_PUSH = 'scm-push'
222+
HOOK_TYPE_SCM_CREATE = 'scm-create'
222223

223224
# Store Settings
224225
DEFAULT_STORE_NAME = 'mongo'

orchestrator/views/hooks.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,19 @@ def post(self, request_data=None, **kwargs):
171171
not request_data.get('deleted'):
172172
ref = basename(request_data['ref'])
173173
commit = request_data['after']
174-
task = handle_callback_hook.delay(
175-
owner, repo, ref, 'scm-push', 'github-push', commit=commit)
174+
# Delay processing of github push event ( eventual consistency)
175+
task = handle_callback_hook.apply_async(
176+
(owner, repo, ref, 'scm-push', 'github-push'),
177+
kwargs={'commit': commit}, countdown=10)
176178
return created_task(task)
177179
elif request.headers.get('X-GitHub-Event') == 'create' and \
178180
request_data.get('ref_type') == 'branch' and \
179181
request_data.get('ref'):
180182
ref = basename(request_data['ref'])
181-
task = handle_callback_hook.delay(
182-
owner, repo, ref, 'scm-create', 'github-create')
183+
# Delay processing of github create event ( eventual consistency)
184+
task = handle_callback_hook.apply_async(
185+
(owner, repo, ref, 'scm-create', 'github-create'),
186+
countdown=10)
183187
return created_task(task)
184188
else:
185189
# Ignore all other hooks

0 commit comments

Comments
 (0)