diff --git a/apps/backend/subscription/tasks.py b/apps/backend/subscription/tasks.py index 590bbf652..943032d2f 100644 --- a/apps/backend/subscription/tasks.py +++ b/apps/backend/subscription/tasks.py @@ -25,6 +25,7 @@ from apps.backend.subscription import tools from apps.backend.subscription.constants import TASK_HOST_LIMIT from apps.backend.subscription.errors import SubscriptionInstanceEmpty +from apps.backend.subscription.handler import SubscriptionTools from apps.backend.subscription.steps import StepFactory, agent from apps.core.gray.tools import GrayTools from apps.node_man import constants, models @@ -712,8 +713,10 @@ def run_subscription_task_and_create_instance( not_exist_instance_id = set(instance_not_in_scope) - set(deleted_instance_info) if not_exist_instance_id: records = list( - models.SubscriptionInstanceRecord.objects.filter( - subscription_id=subscription.id, instance_id__in=not_exist_instance_id, is_latest=True + SubscriptionTools.fetch_latest_record_ids_in_same_inst_id( + models.SubscriptionInstanceRecord.objects.filter( + subscription_id=subscription.id, instance_id__in=not_exist_instance_id + ) ) ) for record in records: