perf: account task timing not triggered (#9564)

Co-authored-by: feng <1304903146@qq.com>
pull/9565/head
fit2bot 2023-02-15 16:48:27 +08:00 committed by GitHub
parent 4109f2cb1c
commit 4ac214e91d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 6 deletions

View File

@ -1,6 +1,6 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from accounts.tasks import execute_automation
from assets.models.automations import (
BaseAutomation as AssetBaseAutomation,
AutomationExecution as AssetAutomationExecution
@ -14,6 +14,10 @@ class AccountBaseAutomation(AssetBaseAutomation):
proxy = True
verbose_name = _("Account automation task")
@property
def execute_task(self):
return execute_automation
@property
def execution_model(self):
return AutomationExecution

View File

@ -3,7 +3,6 @@
from celery import shared_task
from django.utils.translation import gettext_lazy as _
from accounts.models import AccountBackupAutomation
from common.utils import get_object_or_none, get_logger
from orgs.utils import tmp_to_org, tmp_to_root_org
@ -12,6 +11,7 @@ logger = get_logger(__file__)
@shared_task(verbose_name=_('Execute account backup plan'))
def execute_account_backup_plan(pid, trigger):
from accounts.models import AccountBackupAutomation
with tmp_to_root_org():
plan = get_object_or_none(AccountBackupAutomation, pk=pid)
if not plan:

View File

@ -4,12 +4,12 @@ from celery import current_task
from django.db import models
from django.utils.translation import ugettext_lazy as _
from assets.models.node import Node
from assets.models.asset import Asset
from assets.models.node import Node
from assets.tasks import execute_automation
from ops.mixin import PeriodTaskModelMixin
from common.const.choices import Trigger
from common.db.fields import EncryptJsonDictTextField
from ops.mixin import PeriodTaskModelMixin
from orgs.mixins.models import OrgModelMixin, JMSOrgBaseModel
@ -47,9 +47,13 @@ class BaseAutomation(PeriodTaskModelMixin, JMSOrgBaseModel):
assets = self.get_all_assets().prefetch_related('platform')
return assets.group_by_platform()
@property
def execute_task(self):
return execute_automation
def get_register_task(self):
name = f"automation_{self.type}_strategy_period_{str(self.id)[:8]}"
task = execute_automation.name
task = self.execute_task.name
args = (str(self.id), Trigger.timing, self.type)
kwargs = {}
return name, task, args, kwargs

View File

@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
#
import abc
from django.utils.translation import ugettext_lazy as _
from django.db import models
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
from .celery.utils import (