fix: 修复新添加发布机不被调度的问题

pull/11416/head
ibuler 2023-08-24 18:02:56 +08:00
parent f46c9f56e8
commit 5b498650cb
2 changed files with 7 additions and 0 deletions

View File

@ -148,6 +148,11 @@ class Applet(JMSBaseModel):
shutil.copytree(path, pkg_path)
return instance, serializer
@classmethod
def clear_host_prefer(cls):
prefer_key = 'applet_host_prefer_{}'.format("*")
cache.delete_pattern(prefer_key)
def select_host(self, user, asset):
hosts = self.hosts.filter(is_active=True)
hosts = [host for host in hosts if host.load != 'offline']

View File

@ -20,6 +20,8 @@ logger = get_logger(__file__)
def on_applet_host_create(sender, instance, created=False, **kwargs):
if not created:
return
Applet.clear_host_prefer()
applets = Applet.objects.all()
instance.applets.set(applets)