Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第三方插件最大轮询时间调整为 10min,且支持特定插件轮询配置 #7219

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ is_use_celery: True
author: 蓝鲸智云
introduction: 标准运维是通过一套成熟稳定的任务调度引擎,把在多系统间的工作整合到一个流程,助力运维实现跨系统调度自动化的SaaS应用。
introduction_en: SOPS is a SaaS application that utilizes a set of mature and stable task scheduling engines to help realize cross-system scheduling automation, and integrates the work among multiple systems into a single process.
version: 3.31.9
version: 3.31.10
category: 运维工具
language_support: 中文
desktop:
Expand Down
2 changes: 1 addition & 1 deletion app_desc.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
spec_version: 2
app_version: "3.31.9"
app_version: "3.31.10"
app:
region: default
bk_app_code: bk_sops
Expand Down
14 changes: 8 additions & 6 deletions config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
from blueapps.conf.log import get_logging_config_dict
from blueapps.opentelemetry.utils import inject_logging_trace_info
from django.utils.translation import ugettext_lazy as _
from pipeline.celery.queues import ScalableQueues

import env
from gcloud.exceptions import ApiRequestError
from pipeline.celery.queues import ScalableQueues

# 这里是默认的 INSTALLED_APPS,大部分情况下,不需要改动
# 如果你已经了解每个默认 APP 的作用,确实需要去掉某些 APP,请去掉下面的注释,然后修改
Expand Down Expand Up @@ -211,7 +211,7 @@
# mako模板中:<script src="/a.js?v=${ STATIC_VERSION }"></script>
# 如果静态资源修改了以后,上线前改这个版本号即可

STATIC_VERSION = "3.31.9"
STATIC_VERSION = "3.31.10"
DEPLOY_DATETIME = datetime.datetime.now().strftime("%Y%m%d%H%M%S")

STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]
Expand Down Expand Up @@ -489,12 +489,11 @@ def _(s):
PERIODIC_TASK_QUEUE_NAME = "periodic_task_queue"
ScalableQueues.add(name=PERIODIC_TASK_QUEUE_NAME)

from pipeline.celery.settings import * # noqa
from pipeline.eri.celery import queues as eri_queues # noqa

from gcloud.contrib.cleaner import settings as cleaner_settings # noqa
from gcloud.taskflow3.celery import settings as taskflow3_celery_settings # noqa
from gcloud.taskflow3.domains.queues import PrepareAndStartTaskQueueResolver # noqa
from pipeline.celery.settings import * # noqa
from pipeline.eri.celery import queues as eri_queues # noqa

API_TASK_QUEUE_NAME_V2 = "api"
PERIODIC_TASK_QUEUE_NAME_V2 = "periodic_task"
Expand Down Expand Up @@ -676,7 +675,6 @@ def monitor_report_config():

from bk_monitor_report import MonitorReporter # noqa
from bk_monitor_report.contrib.celery import MonitorReportStep # noqa

from blueapps.core.celery import celery_app # noqa

reporter = MonitorReporter(
Expand Down Expand Up @@ -832,3 +830,7 @@ def check_engine_admin_permission(request, *args, **kwargs):

# 任务列表过滤失败任务最大天数
TASK_LIST_STATUS_FILTER_DAYS = env.BKPAAS_TASK_LIST_STATUS_FILTER_DAYS

# 第三方插件特殊轮询时间配置
REMOTE_PLUGIN_FIX_INTERVAL_CODES = env.REMOTE_PLUGIN_FIX_INTERVAL_CODES
REMOTE_PLUGIN_FIX_INTERVAL = env.REMOTE_PLUGIN_FIX_INTERVAL
7 changes: 7 additions & 0 deletions env.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,10 @@

# 默认六个月
BKPAAS_TASK_LIST_STATUS_FILTER_DAYS = int(os.getenv("BKPAAS_TASK_LIST_STATUS_FILTER_DAYS", 180))

# 第三方插件特殊轮询时间配置
REMOTE_PLUGIN_FIX_INTERVAL_CODES_STR = os.getenv("BKAPP_REMOTE_PLUGIN_FIX_INTERVAL_CODES", "")
REMOTE_PLUGIN_FIX_INTERVAL_CODES = (
REMOTE_PLUGIN_FIX_INTERVAL_CODES_STR.split(",") if REMOTE_PLUGIN_FIX_INTERVAL_CODES_STR else []
)
REMOTE_PLUGIN_FIX_INTERVAL = int(os.getenv("BKAPP_REMOTE_PLUGIN_FIX_INTERVAL", 60))
10 changes: 7 additions & 3 deletions pipeline_plugins/components/collections/remote_plugin/v1_0_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
"""
import logging

from django.conf import settings
from django.utils.translation import ugettext_lazy as _

from pipeline.component_framework.component import Component
from pipeline.core.flow import AbstractIntervalGenerator, Service
from pipeline.core.flow.io import StringItemSchema

from pipeline_plugins.components.utils.sites.open.utils import get_node_callback_url
from plugin_service.conf import PLUGIN_LOGGER
from plugin_service.exceptions import PluginServiceException
Expand All @@ -43,8 +44,8 @@ def __init__(self):

def next(self):
super(StepIntervalGenerator, self).next()
# 最小 10s,最大 3600s 一次
return self.fix_interval or (10 if self.count < 30 else min((self.count - 25) ** 2, 3600))
# 最小 10s,最大 600s 一次
return self.fix_interval or (10 if self.count < 30 else min((self.count - 25) ** 2, 600))


class RemotePluginService(Service):
Expand Down Expand Up @@ -119,6 +120,9 @@ def schedule(self, data, parent_data, callback_data=None):
plugin_code = data.get_one_of_inputs("plugin_code")
trace_id = data.get_one_of_outputs("trace_id")

if plugin_code in settings.REMOTE_PLUGIN_FIX_INTERVAL_CODES:
self.interval.fix_interval = settings.REMOTE_PLUGIN_FIX_INTERVAL

try:
plugin_client = PluginServiceApiClient(plugin_code)
except PluginServiceException as e:
Expand Down
Loading