diff --git a/cms/service/ProxyService.py b/cms/service/ProxyService.py index 0d1b56ec3c..68b30271ab 100644 --- a/cms/service/ProxyService.py +++ b/cms/service/ProxyService.py @@ -9,6 +9,7 @@ # Copyright © 2015 Luca Versari # Copyright © 2015 William Di Luigi # Copyright © 2016 Amir Keivan Mohtashami +# Copyright © 2019 Edoardo Morassutto # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -476,6 +477,15 @@ 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 %d 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.", @@ -511,6 +521,15 @@ 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 %d 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.", @@ -545,6 +564,15 @@ 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)