Skip to content

Commit

Permalink
undo unnecesary atomic statements as per discussion
Browse files Browse the repository at this point in the history
Signed-off-by: Alex <aizquier@redhat.com>
  • Loading branch information
Alex-Izquierdo committed Feb 14, 2024
1 parent 8a9414e commit e25a51e
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/aap_eda/services/activation/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,27 +1041,26 @@ def _create_activation_instance(self):
if hasattr(self.db_instance, "git_hash")
else ""
)
with transaction.atomic():
if not self.check_new_process_allowed(
self.db_instance_type,
self.db_instance.id,
):
msg = (
"Failed to create rulebook process. "
"Reason: Max running processes reached. "
"Waiting for a free slot."
)
self._set_activation_status(ActivationStatus.PENDING, msg)
raise exceptions.MaxRunningProcessesError

if not self.check_new_process_allowed(
self.db_instance_type,
self.db_instance.id,
):
msg = (
"Failed to create rulebook process. "
"Reason: Max running processes reached. "
"Waiting for a free slot."
)
self._set_activation_status(ActivationStatus.PENDING, msg)
raise exceptions.MaxRunningProcessesError
args = {
"name": self.db_instance.name,
"status": ActivationStatus.STARTING,
"git_hash": git_hash,
}
args[f"{self.db_instance_type}"] = self.db_instance
try:
with transaction.atomic():
models.RulebookProcess.objects.create(**args)
models.RulebookProcess.objects.create(**args)
except IntegrityError as exc:
msg = (
f"Activation {self.db_instance.id} failed to create "
Expand Down

0 comments on commit e25a51e

Please sign in to comment.