Skip to content
Snippets Groups Projects
Unverified Commit bc2a337b authored by Edoardo Morassutto's avatar Edoardo Morassutto Committed by GitHub
Browse files

Ignore wrong contest submissions in ProxyService (#1142)

* Ignore wrong contest submissions in ProxyService

When you are running cms with more than a contest (ie multicontest)
ProxyService can be notified by ScoringService of new submissions of any
contest, ignoring the `-c X` flag of PS. This will lead to `Inconsistent Data`
errors in RWS due to submissions of the wrong contest (bad user, bad
task, ...). This is especially bad because the wrong submission can be sent
with other valid submissions, and RWS drop them all.

The proposed fix just ignores those submissions from ProxyService since
ScoringService has no way to know which contest PS is bound to.

* Move the contest_id checks in submission_scored/tokened

* Move PS contest checks before submission validation

Filter out the submissions from the wrong contest before rejecting them
if they are hidden/unofficial. Add also some debug logging when it
happens.

This also adds the check in dataset_updated() since AWS may trigger the
same kind of wrong RWS notifications.

* Fix line lengths and message format
parent a9fa3746
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
# Copyright © 2015 Luca Versari <veluca93@gmail.com> # Copyright © 2015 Luca Versari <veluca93@gmail.com>
# Copyright © 2015 William Di Luigi <williamdiluigi@gmail.com> # Copyright © 2015 William Di Luigi <williamdiluigi@gmail.com>
# Copyright © 2016 Amir Keivan Mohtashami <akmohtashami97@gmail.com> # Copyright © 2016 Amir Keivan Mohtashami <akmohtashami97@gmail.com>
# Copyright © 2019 Edoardo Morassutto <edoardo.morassutto@gmail.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
...@@ -476,6 +477,15 @@ class ProxyService(TriggeredService): ...@@ -476,6 +477,15 @@ class ProxyService(TriggeredService):
"unexistent submission id %s.", submission_id) "unexistent submission id %s.", submission_id)
raise KeyError("Submission not found.") raise KeyError("Submission not found.")
# ScoringService sent us a submission of another contest, they
# do not know about our contest_id in multicontest setup.
if submission.task.contest_id != self.contest_id:
logger.debug("Ignoring submission %d of contest %d "
"(this ProxyService considers contest %d only).",
submission.id, submission.task.contest_id,
self.contest_id)
return
if submission.participation.hidden: if submission.participation.hidden:
logger.info("[submission_scored] Score for submission %d " logger.info("[submission_scored] Score for submission %d "
"not sent because the participation is hidden.", "not sent because the participation is hidden.",
...@@ -511,6 +521,15 @@ class ProxyService(TriggeredService): ...@@ -511,6 +521,15 @@ class ProxyService(TriggeredService):
"unexistent submission id %s.", submission_id) "unexistent submission id %s.", submission_id)
raise KeyError("Submission not found.") raise KeyError("Submission not found.")
# ScoringService sent us a submission of another contest, they
# do not know about our contest_id in multicontest setup.
if submission.task.contest_id != self.contest_id:
logger.debug("Ignoring submission %d of contest %d "
"(this ProxyService considers contest %d only).",
submission.id, submission.task.contest_id,
self.contest_id)
return
if submission.participation.hidden: if submission.participation.hidden:
logger.info("[submission_tokened] Token for submission %d " logger.info("[submission_tokened] Token for submission %d "
"not sent because participation is hidden.", "not sent because participation is hidden.",
...@@ -545,6 +564,15 @@ class ProxyService(TriggeredService): ...@@ -545,6 +564,15 @@ class ProxyService(TriggeredService):
task = Task.get_from_id(task_id, session) task = Task.get_from_id(task_id, session)
dataset = task.active_dataset dataset = task.active_dataset
# This ProxyService may focus on a different contest, and it should
# ignore this update.
if task.contest_id != self.contest_id:
logger.debug("Ignoring dataset change for task %d of contest "
"%d (this ProxyService considers contest %d "
"only).", task_id, task.contest.id,
self.contest_id)
return
logger.info("Dataset update for task %d (dataset now is %d).", logger.info("Dataset update for task %d (dataset now is %d).",
task.id, dataset.id) task.id, dataset.id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment