Skip to content

Commit

Permalink
[BUGFIX] Fix race condition between process and index alerts #251 #250
Browse files Browse the repository at this point in the history
Need to wait until our blacklist is processed before trying to process our index
  • Loading branch information
kfdm authored Mar 3, 2020
2 parents 972b712 + 631bf32 commit 0e80721
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 4 additions & 0 deletions promgen/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def process_alert(alert_pk):
alert.delete()
return

# After processing our blacklist, it should be safe to queue our
# alert to also index the labels
index_alert.delay(alert.pk)

# Now that we have our routable items, we want to check which senders are
# configured and expand those as needed
senders = collections.defaultdict(set)
Expand Down
1 change: 0 additions & 1 deletion promgen/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,6 @@ def post(self, request, *args, **kwargs):
# when we run tasks.process_alert
alert = models.Alert.objects.create(body=request.body.decode("utf-8"))
tasks.process_alert.delay(alert.pk)
tasks.index_alert.delay(alert.pk)
return HttpResponse("OK", status=202)


Expand Down

0 comments on commit 0e80721

Please sign in to comment.