Skip to content

Commit

Permalink
Move PS contest checks before submission validation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
edomora97 committed Dec 13, 2021
1 parent 295b7f4 commit babed7c
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions cms/service/ProxyService.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,14 @@ def submission_scored(self, submission_id):
"unexistent submission id %s.", submission_id)
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 %s of contest %d "
"(this ProxyService considers contest %d only)",
submission.id, submission.task.contest_id, self.contest_id)
return

if submission.participation.hidden:
logger.info("[submission_scored] Score for submission %d "
"not sent because the participation is hidden.",
Expand All @@ -489,11 +497,6 @@ def submission_scored(self, submission_id):
submission_id)
return

# 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:
return

# Update RWS.
for operation in self.operations_for_score(submission):
self.enqueue(operation)
Expand All @@ -517,6 +520,14 @@ def submission_tokened(self, submission_id):
"unexistent submission id %s.", submission_id)
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 %s of contest %d "
"(this ProxyService considers contest %d only)",
submission.id, submission.task.contest_id, self.contest_id)
return

if submission.participation.hidden:
logger.info("[submission_tokened] Token for submission %d "
"not sent because participation is hidden.",
Expand All @@ -529,11 +540,6 @@ def submission_tokened(self, submission_id):
submission_id)
return

# 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:
return

# Update RWS.
for operation in self.operations_for_token(submission):
self.enqueue(operation)
Expand All @@ -556,6 +562,14 @@ def dataset_updated(self, task_id):
task = Task.get_from_id(task_id, session)
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).",
task.id, dataset.id)

Expand Down

0 comments on commit babed7c

Please sign in to comment.