Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-28 07:24:56

0001 """Purge `workinggroup` from alarm configs.
0002 
0003 There is one and only one working group in this deployment: EIC. Filtering
0004 on it carries no signal, so the field is being removed from every alarm
0005 config's `data.params` and from any English prose that mentions EIC/working
0006 group. Title of the catch-all is normalised to "catch-all".
0007 
0008 Idempotent: re-running is a no-op. Reverse is a no-op (we don't restore
0009 EIC references).
0010 """
0011 from __future__ import annotations
0012 
0013 from django.db import migrations
0014 
0015 
0016 CONTEXT_NAME = 'swf-alarms'
0017 
0018 
0019 TITLE_MAP = {
0020     'alarm_panda_failure_rate_sakib':
0021         "PanDA task failure rate — Sakib's tasks",
0022     'alarm_panda_failure_rate_eic_all':
0023         'PanDA task failure rate — catch-all',
0024 }
0025 
0026 
0027 CONTENT_MAP = {
0028     'alarm_panda_failure_rate_sakib': (
0029         "Alert on PanDA tasks owned by Sakib Rahman whose computed "
0030         "failure rate exceeds the configured threshold over the "
0031         "configured window. Threshold, window, and minimum terminal "
0032         "jobs are in the Check params below.\n"
0033         "\n"
0034         "Dashboard: https://epic-devcloud.org/prod/alarms/\n"
0035     ),
0036     'alarm_panda_failure_rate_eic_all': (
0037         "Catch-all alert on any PanDA task whose computed failure rate "
0038         "exceeds the configured threshold over the configured window. "
0039         "Torre-only tuning channel for shaping future per-owner alarms. "
0040         "Threshold and window live in the Check params below.\n"
0041     ),
0042 }
0043 
0044 
0045 def purge(apps, schema_editor):
0046     Entry = apps.get_model('remote_app', 'Entry')
0047     qs = Entry.objects.filter(context__name=CONTEXT_NAME, kind='alarm',
0048                               deleted_at__isnull=True)
0049     for e in qs:
0050         data = dict(e.data or {})
0051         params = dict(data.get('params') or {})
0052         dirty = False
0053         if 'workinggroup' in params:
0054             params.pop('workinggroup', None)
0055             data['params'] = params
0056             dirty = True
0057         eid = data.get('entry_id') or ''
0058         if eid in TITLE_MAP and e.title != TITLE_MAP[eid]:
0059             e.title = TITLE_MAP[eid]
0060             dirty = True
0061         if eid in CONTENT_MAP and e.content != CONTENT_MAP[eid]:
0062             e.content = CONTENT_MAP[eid]
0063             dirty = True
0064         if dirty:
0065             e.data = data
0066             e.save()
0067 
0068 
0069 def noop(apps, schema_editor):
0070     pass
0071 
0072 
0073 class Migration(migrations.Migration):
0074     dependencies = [('remote_app', '0003_seed_teams')]
0075     operations = [migrations.RunPython(purge, noop)]