From 26029e466c9a07c980a47bb87e7901272397681f Mon Sep 17 00:00:00 2001 From: liujun Date: Tue, 26 Mar 2024 19:36:21 +0800 Subject: [PATCH 01/12] =?UTF-8?q?perf:=20=E5=91=A8=E6=9C=9F=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=E6=89=A7=E8=A1=8C=E4=BA=BA=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=91=A8=E6=9C=9F=E6=9B=B4=E6=96=B0=E4=BA=BA=20#7368?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 2 +- gcloud/core/apis/drf/viewsets/periodic_task.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e599933bae..196ed9ed72 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: hooks: - id: check-merge-conflict - repo: https://github.com/psf/black - rev: stable + rev: 22.8.0 hooks: - id: black language_version: python3.6 diff --git a/gcloud/core/apis/drf/viewsets/periodic_task.py b/gcloud/core/apis/drf/viewsets/periodic_task.py index f13f189457..3ae69ecd13 100644 --- a/gcloud/core/apis/drf/viewsets/periodic_task.py +++ b/gcloud/core/apis/drf/viewsets/periodic_task.py @@ -268,5 +268,7 @@ def partial_update(self, request, *args, **kwargs): instance.task.save(update_fields=["name"]) instance.editor = request.user.username instance.save(update_fields=["editor", "edit_time"]) + instance.task.creator = request.user.username + instance.task.save() return Response(PeriodicTaskReadOnlySerializer(instance=instance).data) From a2cc98f54179e33e2f233f68583999811f4ea127 Mon Sep 17 00:00:00 2001 From: lTimej <65690352+lTimej@users.noreply.github.com> Date: Mon, 15 Apr 2024 20:56:49 +0800 Subject: [PATCH 02/12] =?UTF-8?q?perf:=20=E5=91=A8=E6=9C=9F=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E8=BF=90=E8=90=A5=E4=BC=98=E5=8C=96=20#7364=20(#7399)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * perf: 周期任务运营优化 #7364 * perf: 周期任务运营优化 #7364 * perf: 周期任务,所有开启的周期任务一起排到前列 #7405 * perf: 周期任务运营优化 #7364 * perf: 周期任务运营优化 #7364 --- config/default.py | 9 + env.py | 11 + gcloud/contrib/admin/urls.py | 1 + gcloud/contrib/admin/views/command.py | 9 +- .../core/apis/drf/viewsets/periodic_task.py | 2 +- gcloud/core/tasks.py | 112 ++++++- .../core/period_task_notice_mail.html | 281 ++++++++++++++++++ 7 files changed, 417 insertions(+), 8 deletions(-) create mode 100644 gcloud/core/templates/core/period_task_notice_mail.html diff --git a/config/default.py b/config/default.py index ae0ae5969b..61b54eecd7 100644 --- a/config/default.py +++ b/config/default.py @@ -842,3 +842,12 @@ def check_engine_admin_permission(request, *args, **kwargs): # 通知中心 BK_NOTICE = {"BK_API_URL_TMPL": env.BK_APIGW_URL_TMPL or ""} + +# 周期任务自动关闭扫描频率 +PERIODIC_TASK_REMINDER_TIME = env.PERIODIC_TASK_REMINDER_TIME + +# 周期任务自动关闭扫描周期 +PERIODIC_TASK_REMINDER_SCAN_CRON = env.PERIODIC_TASK_REMINDER_SCAN_CRON + +# 周期任务消息通知类型 +PERIODIC_TASK_REMINDER_NOTIFY_TYPE = env.PERIODIC_TASK_REMINDER_NOTIFY_TYPE diff --git a/env.py b/env.py index 63ecf9ebbf..04b8aaafe7 100644 --- a/env.py +++ b/env.py @@ -127,3 +127,14 @@ 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)) + +# 周期任务自动关闭扫描频率(单位:月) +PERIODIC_TASK_REMINDER_TIME = int(os.getenv("BKAPP_PERIODIC_TASK_REMINDER_TIME", 1)) + +# 周期任务自动关闭扫描周期 +PERIODIC_TASK_REMINDER_SCAN_CRON = json.loads( + os.getenv("BKAPP_PERIODIC_TASK_REMINDER_SCAN_CRON", '{"hour": "23", "minute": "0"}') +) + +# 周期任务消息通知类型 +PERIODIC_TASK_REMINDER_NOTIFY_TYPE = json.loads(os.getenv("PERIODIC_TASK_REMINDER_NOTIFY_TYPE", '["email"]')) diff --git a/gcloud/contrib/admin/urls.py b/gcloud/contrib/admin/urls.py index 4cd0203230..677e9965f3 100644 --- a/gcloud/contrib/admin/urls.py +++ b/gcloud/contrib/admin/urls.py @@ -57,4 +57,5 @@ url(r"^batch_insert_project_based_component/$", batch_insert_project_based_component), url(r"^batch_delete_project_based_component/$", batch_delete_project_based_component), url(r"^batch_revoke_task/$", batch_revoke_task), + url(r"^command/get_enabled_periodic_task/$", views.get_enabled_periodic_task), ] diff --git a/gcloud/contrib/admin/views/command.py b/gcloud/contrib/admin/views/command.py index 87015f96ae..cea85d1302 100644 --- a/gcloud/contrib/admin/views/command.py +++ b/gcloud/contrib/admin/views/command.py @@ -27,7 +27,7 @@ from gcloud.contrib.admin.utils import force_tasks from gcloud.core.decorators import check_is_superuser from gcloud.core.models import ProjectBasedComponent -from gcloud.core.tasks import migrate_pipeline_parent_data_task +from gcloud.core.tasks import migrate_pipeline_parent_data_task, scan_periodic_task from gcloud.openapi.schema import AnnotationAutoSchema from gcloud.taskflow3.models import TaskFlowInstance, TaskFlowRelation @@ -197,3 +197,10 @@ def batch_revoke_task(request): return JsonResponse({"result": False, "data": [], "message": "存在终止异常的任务 = {}".format(revoke_failed_tasks)}) return JsonResponse({"result": True, "data": [], "message": f"revoked -> {tasks.count()}"}) + + +@check_is_superuser() +def get_enabled_periodic_task(request): + is_send_notify = True if request.GET.get("is_send_notify", "false") == "true" else False + data = scan_periodic_task(is_send_notify) + return JsonResponse({"result": True, "code": err_code.SUCCESS.code, "data": data}) diff --git a/gcloud/core/apis/drf/viewsets/periodic_task.py b/gcloud/core/apis/drf/viewsets/periodic_task.py index 3ae69ecd13..6fe9b69dce 100644 --- a/gcloud/core/apis/drf/viewsets/periodic_task.py +++ b/gcloud/core/apis/drf/viewsets/periodic_task.py @@ -182,7 +182,7 @@ def list(self, request, *args, **kwargs): if project_id: order_by = request.query_params.get("order_by") or "-id" - orderings = ("-is_collected", order_by) + orderings = ("-is_collected", "-task__celery_task__enabled", order_by) collection_task_ids, collection_task_map = Collection.objects.get_user_project_collection_instance_info( project_id=project_id, username=request.user.username, category="periodic_task" diff --git a/gcloud/core/tasks.py b/gcloud/core/tasks.py index 666aed48b8..997663a381 100644 --- a/gcloud/core/tasks.py +++ b/gcloud/core/tasks.py @@ -11,25 +11,31 @@ specific language governing permissions and limitations under the License. """ +import datetime import logging import time import traceback from contextlib import contextmanager -from django.contrib.sessions.models import Session -from django.core.cache import cache +import dateutil.relativedelta from celery import task from celery.five import monotonic from celery.task import periodic_task +from django.contrib.sessions.models import Session +from django.core.cache import cache +from django.template.loader import render_to_string from django.utils import timezone +from django_celery_beat.models import PeriodicTask as DjangoCeleryBeatPeriodicTask +from pipeline.contrib.periodic_task.djcelery.tzcrontab import TzAwareCrontab +from pipeline.engine.core.data.api import _backend, _candidate_backend +from pipeline.engine.core.data.redis_backend import RedisDataBackend from gcloud import exceptions from gcloud.conf import settings +from gcloud.core.api_adapter.user_info import get_user_info from gcloud.core.project import sync_projects_from_cmdb - -from pipeline.engine.core.data.api import _backend, _candidate_backend -from pipeline.engine.core.data.redis_backend import RedisDataBackend -from pipeline.contrib.periodic_task.djcelery.tzcrontab import TzAwareCrontab +from gcloud.periodictask.models import PeriodicTask +from gcloud.shortcuts.message.send_msg import send_message logger = logging.getLogger("celery") @@ -121,3 +127,97 @@ def migrate_pipeline_parent_data_task(): logger.exception("[migrate_pipeline_parent_data] {} key migrate err.".format(i)) logger.info("[migrate_pipeline_parent_data] migrate done!") + + +@periodic_task(run_every=TzAwareCrontab(minute=0, hour="*/2")) +def cmdb_business_sync_shutdown_period_task(): + task_id = cmdb_business_sync_shutdown_period_task.request.id + with redis_lock(LOCK_ID, task_id) as acquired: + if acquired: + logger.info("Start sync business from cmdb...") + try: + task_ids = [ + item["task__celery_task__id"] + for item in PeriodicTask.objects.filter(project__is_disable=True).values("task__celery_task__id") + ] + DjangoCeleryBeatPeriodicTask.objects.filter(id__in=task_ids).update(enabled=False) + except exceptions.APIError as e: + logger.error( + "An error occurred when sync cmdb business, message: {msg}, trace: {trace}".format( + msg=str(e), trace=traceback.format_exc() + ) + ) + else: + logger.info("Can not get sync_business lock, sync operation abandon") + + +@task +def send_periodic_task_notify(executor, notify_type, receivers, title, content): + try: + send_message(executor, notify_type, receivers, title, content) + except Exception as e: + logger.exception(f"send periodic task notify error: {e}") + + +@periodic_task(run_every=TzAwareCrontab(**settings.PERIODIC_TASK_REMINDER_SCAN_CRON)) +def scan_periodic_task(is_send_notify: bool = True): + title = "【标准运维 APP 提醒】请确认您正在运行的周期任务状态" + # 以执行人维度发邮件通知 + periodic_tasks = ( + PeriodicTask.objects.filter(task__celery_task__enabled=True) + .values( + "id", + "task__creator", + "project__id", + "project__name", + "edit_time", + "task__last_run_at", + "task__name", + "task__total_run_count", + ) + .order_by("-edit_time") + ) + data = {} + for p_task in periodic_tasks: + last_month_time = datetime.datetime.now() + dateutil.relativedelta.relativedelta( + months=-int(settings.PERIODIC_TASK_REMINDER_TIME) + ) + if last_month_time.timestamp() < p_task["edit_time"].timestamp(): + continue + creator = p_task["task__creator"] + project_name = p_task["project__name"] + task_dict = { + "edit_time": p_task["edit_time"], + "last_run_at": p_task["task__last_run_at"], + "name": p_task["task__name"], + "total_run_count": p_task["task__total_run_count"], + "task_link": settings.BK_SOPS_HOST + + f"/taskflow/home/periodic/{p_task['project__id']}/?limit=15&page=1&task_id={p_task['id']}", + } + if creator in data: + if project_name in data[creator]: + data[creator][project_name].append(task_dict) + else: + data[creator][project_name] = [task_dict] + else: + data[creator] = {project_name: [task_dict]} + # 发送通知 + if is_send_notify: + for notifier, tasks in data.items(): + try: + user_info = get_user_info(notifier) + mail_content = render_to_string( + "core/period_task_notice_mail.html", + { + "notifier": notifier, + "ch_notifier": user_info["data"]["bk_username"], + "period_task_times": settings.PERIODIC_TASK_REMINDER_TIME, + "task_projects": tasks, + }, + ) + send_periodic_task_notify.delay( + "admin", settings.PERIODIC_TASK_REMINDER_NOTIFY_TYPE, "liujun", title, mail_content + ) + except Exception as e: + logger.exception(f"send periodic task notify error: {e}") + return data diff --git a/gcloud/core/templates/core/period_task_notice_mail.html b/gcloud/core/templates/core/period_task_notice_mail.html new file mode 100644 index 0000000000..fc53397690 --- /dev/null +++ b/gcloud/core/templates/core/period_task_notice_mail.html @@ -0,0 +1,281 @@ + + + + + + 【标准运维 APP 提醒】请确认您正在运行的周期任务状态 + + + + + + +
+
+
+ + 标准运维 +
+
+ + + + +
+
你好, {{ notifier }}({{ ch_notifier }})
+
+ 检测到你有以下周期任务在过去 + {{ period_task_times }} + 个月的检测周期内没有进行任何更新,请核查这些周期任务是否仍在使用 +
+ {% for project_name, task_project in task_projects.items %} + + + + + + + + +
+
+ + + + + + + + + + + + {% for task in task_project %} + + + + + + + + {% endfor %} + +
+ 任务名称 + + 更新时间 + + 上次运行时间 + + 检测周期运行次数 + + 任务查看链接 +
+ {{ task.name }} + + {{ task.edit_time }} + + {{ task.last_run_at }} + + {{ task.total_run_count }} + + {{ task.task_link }} +
+
+ {% endfor %} +
+
+ + From 0816ee2f110a1853132bb6ba066b498a10d2e19c Mon Sep 17 00:00:00 2001 From: v_xugzhou <941071842@qq.com> Date: Mon, 8 Apr 2024 16:48:18 +0800 Subject: [PATCH 03/12] =?UTF-8?q?fix:=20=E5=91=A8=E6=9C=9F=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=BC=96=E8=BE=91=E4=B8=8B=E6=8B=89=E6=A1=86=20value?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E9=97=AE=E9=A2=98=20--bug=3D116848222?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../desktop/src/components/common/RenderForm/FormItem.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/desktop/src/components/common/RenderForm/FormItem.vue b/frontend/desktop/src/components/common/RenderForm/FormItem.vue index 6d53b47681..e11a2feeb6 100644 --- a/frontend/desktop/src/components/common/RenderForm/FormItem.vue +++ b/frontend/desktop/src/components/common/RenderForm/FormItem.vue @@ -405,6 +405,11 @@ return '******' } + // 元变量表单数据为Object格式时,取默认值 + if (this.constants[this.scheme.tag_code]?.is_meta && checkDataType(val) === 'Object') { + return val.default + } + if (defaultValueType.includes(valueType)) { formValue = tools.deepClone(val) } else { From aa0de01a5d3e73b1399503770c2de1831addaf36 Mon Sep 17 00:00:00 2001 From: liujun Date: Wed, 17 Apr 2024 11:49:21 +0800 Subject: [PATCH 04/12] feat: release V3.32.0 #ignore --- app.yml | 2 +- app_desc.yaml | 2 +- config/default.py | 2 +- version_logs_md/V3.32.0_2024-04-16.md | 11 +++++++++++ version_logs_md_en/V3.32.0_2024-04-16.md | 13 +++++++++++++ 5 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 version_logs_md/V3.32.0_2024-04-16.md create mode 100644 version_logs_md_en/V3.32.0_2024-04-16.md diff --git a/app.yml b/app.yml index 269d74e47d..3d1d8fce8f 100644 --- a/app.yml +++ b/app.yml @@ -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.25 +version: 3.32.0 category: 运维工具 language_support: 中文 desktop: diff --git a/app_desc.yaml b/app_desc.yaml index 9ca6c3ca88..4afe9b0f6a 100644 --- a/app_desc.yaml +++ b/app_desc.yaml @@ -1,5 +1,5 @@ spec_version: 2 -app_version: "3.31.25" +app_version: "3.32.0" app: region: default bk_app_code: bk_sops diff --git a/config/default.py b/config/default.py index c73fc3b863..db7a49e986 100644 --- a/config/default.py +++ b/config/default.py @@ -213,7 +213,7 @@ # mako模板中: # 如果静态资源修改了以后,上线前改这个版本号即可 -STATIC_VERSION = "3.31.25" +STATIC_VERSION = "3.32.0" DEPLOY_DATETIME = datetime.datetime.now().strftime("%Y%m%d%H%M%S") STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")] diff --git a/version_logs_md/V3.32.0_2024-04-16.md b/version_logs_md/V3.32.0_2024-04-16.md new file mode 100644 index 0000000000..0aa0f8b4cd --- /dev/null +++ b/version_logs_md/V3.32.0_2024-04-16.md @@ -0,0 +1,11 @@ +# V3.32.0 版本更新说明 + +### 优化 + +- [ 优化 ] 周期任务的执行人改为周期策略的最后更新人 +- [ 优化 ] 周期任务列表,已开启的任务置顶展示 +- [ 优化 ] 长期未更新的周期任务,增加邮件提醒 + +### 修复 + +- [修复] 修复编辑周期任务的参数时,下拉框数据错误问题 \ No newline at end of file diff --git a/version_logs_md_en/V3.32.0_2024-04-16.md b/version_logs_md_en/V3.32.0_2024-04-16.md new file mode 100644 index 0000000000..a6a2c76ec0 --- /dev/null +++ b/version_logs_md_en/V3.32.0_2024-04-16.md @@ -0,0 +1,13 @@ +# V3.32.0 Release Note + +### Improved + +- [Improved] The executor for "Cron Task" has been changed to the last updater of the cron task. + +- [Improved] The list of cron tasks now displays enabled tasks at the top. + +- [Improved] Added email reminders for cron tasks that have not been updated for a long time. + +### Fixed + +- [Fixed] Fixed an issue where the dropdown data was incorrect when editing parameters for cron tasks \ No newline at end of file From c9f213c9b45349fbd8b4830ec10d69e5c89dff61 Mon Sep 17 00:00:00 2001 From: liujun Date: Wed, 17 Apr 2024 12:56:10 +0800 Subject: [PATCH 05/12] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=91=A8=E6=9C=9F=E4=BB=BB=E5=8A=A1=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=91=A8=E6=9C=9F=E6=97=B6=E9=97=B4=20#7364?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/default.py | 3 +++ env.py | 5 ++++- gcloud/core/tasks.py | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/default.py b/config/default.py index db7a49e986..a575ff0c2a 100644 --- a/config/default.py +++ b/config/default.py @@ -850,6 +850,9 @@ def check_engine_admin_permission(request, *args, **kwargs): # 周期任务自动关闭扫描频率 PERIODIC_TASK_REMINDER_TIME = env.PERIODIC_TASK_REMINDER_TIME +# 发送周期任务消息通知开关(默认关) +PERIODIC_TASK_REMINDER_SWITCH = env.PERIODIC_TASK_REMINDER_SWITCH + # 周期任务自动关闭扫描周期 PERIODIC_TASK_REMINDER_SCAN_CRON = env.PERIODIC_TASK_REMINDER_SCAN_CRON diff --git a/env.py b/env.py index 04b8aaafe7..f7b8426663 100644 --- a/env.py +++ b/env.py @@ -131,9 +131,12 @@ # 周期任务自动关闭扫描频率(单位:月) PERIODIC_TASK_REMINDER_TIME = int(os.getenv("BKAPP_PERIODIC_TASK_REMINDER_TIME", 1)) +# 发送周期任务消息通知开关 +PERIODIC_TASK_REMINDER_SWITCH = int(os.getenv("BKAPP_PERIODIC_TASK_REMINDER_SWITCH", 0)) + # 周期任务自动关闭扫描周期 PERIODIC_TASK_REMINDER_SCAN_CRON = json.loads( - os.getenv("BKAPP_PERIODIC_TASK_REMINDER_SCAN_CRON", '{"hour": "23", "minute": "0"}') + os.getenv("BKAPP_PERIODIC_TASK_REMINDER_SCAN_CRON", '{"hour": "10", "minute": "20"}') ) # 周期任务消息通知类型 diff --git a/gcloud/core/tasks.py b/gcloud/core/tasks.py index 997663a381..333b2771b2 100644 --- a/gcloud/core/tasks.py +++ b/gcloud/core/tasks.py @@ -161,6 +161,8 @@ def send_periodic_task_notify(executor, notify_type, receivers, title, content): @periodic_task(run_every=TzAwareCrontab(**settings.PERIODIC_TASK_REMINDER_SCAN_CRON)) def scan_periodic_task(is_send_notify: bool = True): + if not settings.PERIODIC_TASK_REMINDER_SWITCH: + return title = "【标准运维 APP 提醒】请确认您正在运行的周期任务状态" # 以执行人维度发邮件通知 periodic_tasks = ( @@ -216,7 +218,7 @@ def scan_periodic_task(is_send_notify: bool = True): }, ) send_periodic_task_notify.delay( - "admin", settings.PERIODIC_TASK_REMINDER_NOTIFY_TYPE, "liujun", title, mail_content + "admin", settings.PERIODIC_TASK_REMINDER_NOTIFY_TYPE, notifier, title, mail_content ) except Exception as e: logger.exception(f"send periodic task notify error: {e}") From 9c86e5f676f55957c25c96b46e5016f02a971988 Mon Sep 17 00:00:00 2001 From: liujun Date: Wed, 17 Apr 2024 17:17:36 +0800 Subject: [PATCH 06/12] =?UTF-8?q?perf:=20=E5=91=A8=E6=9C=9F=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5=E6=A8=A1=E7=89=88?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=BC=98=E5=8C=96=20#7364?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gcloud/core/tasks.py | 5 +++-- .../core/templates/core/period_task_notice_mail.html | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gcloud/core/tasks.py b/gcloud/core/tasks.py index 333b2771b2..8ce55eea07 100644 --- a/gcloud/core/tasks.py +++ b/gcloud/core/tasks.py @@ -193,7 +193,7 @@ def scan_periodic_task(is_send_notify: bool = True): "last_run_at": p_task["task__last_run_at"], "name": p_task["task__name"], "total_run_count": p_task["task__total_run_count"], - "task_link": settings.BK_SOPS_HOST + "task_link": settings.BK_SOPS_HOST.rstrip("/") + f"/taskflow/home/periodic/{p_task['project__id']}/?limit=15&page=1&task_id={p_task['id']}", } if creator in data: @@ -206,6 +206,7 @@ def scan_periodic_task(is_send_notify: bool = True): # 发送通知 if is_send_notify: for notifier, tasks in data.items(): + logger.info(f"send a message to {notifier}") try: user_info = get_user_info(notifier) mail_content = render_to_string( @@ -218,7 +219,7 @@ def scan_periodic_task(is_send_notify: bool = True): }, ) send_periodic_task_notify.delay( - "admin", settings.PERIODIC_TASK_REMINDER_NOTIFY_TYPE, notifier, title, mail_content + "admin", settings.PERIODIC_TASK_REMINDER_NOTIFY_TYPE, "liujun", title, mail_content ) except Exception as e: logger.exception(f"send periodic task notify error: {e}") diff --git a/gcloud/core/templates/core/period_task_notice_mail.html b/gcloud/core/templates/core/period_task_notice_mail.html index fc53397690..a357613a2f 100644 --- a/gcloud/core/templates/core/period_task_notice_mail.html +++ b/gcloud/core/templates/core/period_task_notice_mail.html @@ -28,7 +28,7 @@ a { border: none; text-decoration: none !important; - color: #000; + color: blue; } a:hover { @@ -211,9 +211,11 @@
你好, {{ notifier }}({{ ch_notifier }})
- 检测到你有以下周期任务在过去 + 检测到您以下周期任务超过 {{ period_task_times }} - 个月的检测周期内没有进行任何更新,请核查这些周期任务是否仍在使用 + 个月 未操作,请核实是否仍在使用。 +
+ 如不再使用,请暂停或删除任务,以免造成资源浪费。
{% for project_name, task_project in task_projects.items %}