From babed7c2f5f152b637c292ca5ed4e8e6193f5187 Mon Sep 17 00:00:00 2001 From: Edoardo Morassutto Date: Mon, 13 Dec 2021 18:30:09 +0100 Subject: [PATCH] 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. --- cms/service/ProxyService.py | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/cms/service/ProxyService.py b/cms/service/ProxyService.py index 3feed45a43..784796f703 100644 --- a/cms/service/ProxyService.py +++ b/cms/service/ProxyService.py @@ -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.", @@ -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) @@ -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.", @@ -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) @@ -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)