feat: ETCD 备份 + 邮件/飞书通知
ETCD 备份(新增类型): - 后端 core/backup/etcd.py:调用 etcdctl snapshot save(v3.5.17 二进制) 生成快照文件,与 META.txt 一起 tar.gz 流式打包上传。 - 配置支持 endpoints(逗号分隔多节点)、basic auth、TLS(cacert/cert/key)。 - Dockerfile 下载 etcdctl 二进制(绕过 apt 签名问题)。 通知模块: - 核心 app/core/notify.py: - 邮件:smtplib + MIMEMultipart(线程池里跑避免阻塞) - 飞书:httpx 调自定义机器人 webhook,发 interactive card - settings API: - GET/PUT /api/settings/notifications(密码脱敏 *** 编辑占位) - POST /api/settings/notifications/test 测试通道 - Job 增加 notify_on 字段(none/failure/all),Alembic 0002 迁移。 - executor 在 run 完成后根据 job.notify_on 与 run.status 异步触发通知, 重新加载最新 run 信息生成上下文。 前端: - JobForm 加 ETCD 表单字段与 notify_on 选择器;type 选项加 etcd。 - JobList 显示通知策略徽标。 - Settings 页加通知配置卡片:邮件(折叠面板 + 测试按钮)+ 飞书 + 保存。 - 新增 api/settings.ts。 - 类型扩展:EtcdSourceConfig、NotificationsConfig、SmtpConfig。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -41,13 +41,27 @@ class InfluxDBSourceConfigV2(BaseModel):
|
||||
token: str = Field(..., min_length=1)
|
||||
|
||||
|
||||
class EtcdSourceConfig(BaseModel):
|
||||
endpoints: str = Field(
|
||||
...,
|
||||
min_length=1,
|
||||
description="ETCD endpoints,逗号分隔,如 http://10.0.0.1:2379,http://10.0.0.2:2379",
|
||||
)
|
||||
username: str = Field("", description="可选 basic auth 用户名")
|
||||
password: str = Field("")
|
||||
cacert: str = Field("", description="CA 证书路径(容器内)")
|
||||
cert: str = Field("", description="客户端证书路径")
|
||||
key: str = Field("", description="客户端私钥路径")
|
||||
|
||||
|
||||
class JobBase(BaseModel):
|
||||
name: str = Field(..., min_length=1, max_length=64)
|
||||
type: Literal["mysql", "directory", "influxdb"]
|
||||
type: Literal["mysql", "directory", "influxdb", "etcd"]
|
||||
source_config: dict
|
||||
storage_id: int
|
||||
cron_expression: Optional[str] = Field(None, description="标准 5 段 cron 表达式,空表示手动")
|
||||
enabled: bool = True
|
||||
notify_on: Literal["none", "failure", "all"] = Field("none", description="何时发通知")
|
||||
retention_count: int = Field(7, ge=1, le=365)
|
||||
retention_days: Optional[int] = Field(None, ge=1, le=3650)
|
||||
description: Optional[str] = Field(None, max_length=255)
|
||||
@@ -74,6 +88,7 @@ class JobUpdate(BaseModel):
|
||||
storage_id: Optional[int] = None
|
||||
cron_expression: Optional[str] = None
|
||||
enabled: Optional[bool] = None
|
||||
notify_on: Optional[Literal["none", "failure", "all"]] = None
|
||||
retention_count: Optional[int] = Field(None, ge=1, le=365)
|
||||
retention_days: Optional[int] = Field(None, ge=1, le=3650)
|
||||
description: Optional[str] = None
|
||||
@@ -86,6 +101,7 @@ class JobOut(BaseModel):
|
||||
type: str
|
||||
cron_expression: Optional[str]
|
||||
enabled: bool
|
||||
notify_on: str
|
||||
retention_count: int
|
||||
retention_days: Optional[int]
|
||||
description: Optional[str]
|
||||
|
||||
Reference in New Issue
Block a user