fix(auto-repair): preserve exact playbook candidates
This commit is contained in:
@@ -27,7 +27,7 @@ for _api_root in (_IMAGE_API_ROOT, _REPO_API_ROOT):
|
||||
sys.path.insert(0, str(_api_root))
|
||||
break
|
||||
|
||||
from src.models.playbook import (
|
||||
from src.models.playbook import ( # noqa: E402
|
||||
ActionType,
|
||||
Playbook,
|
||||
PlaybookSource,
|
||||
@@ -36,9 +36,9 @@ from src.models.playbook import (
|
||||
RiskLevel,
|
||||
SymptomPattern,
|
||||
)
|
||||
from src.core.redis_client import close_redis_pool, init_redis_pool
|
||||
from src.repositories.playbook_repository import get_playbook_repository
|
||||
from src.utils.timezone import now_taipei
|
||||
from src.core.redis_client import close_redis_pool, init_redis_pool # noqa: E402
|
||||
from src.repositories.playbook_repository import get_playbook_repository # noqa: E402
|
||||
from src.utils.timezone import now_taipei # noqa: E402
|
||||
|
||||
|
||||
DEFAULT_ALERTNAME = "AwoooPAutoRepairCanaryT16"
|
||||
@@ -63,10 +63,11 @@ class SeedResult:
|
||||
def _playbook_id_for_alertname(alertname: str) -> str:
|
||||
if alertname == DEFAULT_ALERTNAME:
|
||||
return "PB-AWOOOP-T16-CANARY"
|
||||
prefix = "PB-AWOOOP-CANARY-"
|
||||
suffix = re.sub(r"[^A-Z0-9]+", "-", alertname.upper()).strip("-")
|
||||
suffix = suffix.replace("AWOOOP-AUTO-REPAIR-CANARY-", "")
|
||||
suffix = suffix[:18] or "T16"
|
||||
return f"PB-AWOOOP-CANARY-{suffix}"
|
||||
suffix = suffix[: 32 - len(prefix)] or "T16"
|
||||
return f"{prefix}{suffix}"
|
||||
|
||||
|
||||
async def seed_canary_playbook(
|
||||
|
||||
Reference in New Issue
Block a user