Warning, file /swf-monitor/src/monitor_app/viewdir/panda_storage_doors.py was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 """The Storage doors page (site-canary docs/STORAGE_DOORS.md): what the
0002 doors production writes through answered when the canary last used them
0003 — a small write, a stat, a delete, and the date on the certificate they
0004 serve — with the settings that govern the cycle.
0005
0006 Reads the cached product the cycle stored and computes nothing: it
0007 touches no door, no catalog and no PanDA. Nothing on this page acts,
0008 and the page says so: the canary reports and production operations act.
0009 """
0010 import logging
0011
0012 from django.shortcuts import render
0013
0014 from monitor_app.panda.storage_doors import DEFAULTS, STATE_KEY
0015
0016 logger = logging.getLogger(__name__)
0017
0018 VERDICT_CLASS = {'up': 'finished_fill', 'down': 'failed_fill', 'unknown': ''}
0019 REASON_LABELS = {
0020 'wrote': 'wrote, read back and deleted',
0021 'refused': 'the door refused the write',
0022 'certificate_expired': 'its certificate has expired',
0023 'no_answer': 'no answer in time',
0024 'not_formed': 'no probe could be made',
0025 'not_permitted': 'the door refused us, not the write',
0026 'stat_unconfirmed': 'written, but the stat did not confirm it',
0027 'canary_credential': "the canary's own credential, not the doors",
0028 'no_xrootd_write_door': 'the catalog gives it no xrootd write door',
0029 }
0030
0031
0032 def _row(rse, state):
0033 evidence = state.get('evidence') or {}
0034 days = evidence.get('certificate_days_left')
0035 return {
0036 'rse': rse,
0037 'verdict': state.get('verdict') or 'unknown',
0038 'verdict_class': VERDICT_CLASS.get(state.get('verdict'), ''),
0039 'reason': state.get('reason') or '',
0040 'reason_label': REASON_LABELS.get(state.get('reason'), state.get('reason') or ''),
0041 'door': state.get('door') or '',
0042 'path': state.get('path') or evidence.get('path') or '',
0043 'certificate': evidence.get('certificate') or '',
0044 'certificate_days': (round(days) if isinstance(days, (int, float)) else None),
0045 'expiring': bool(evidence.get('certificate_expiring')),
0046 'expired': isinstance(days, (int, float)) and days <= 0,
0047 'write_seconds': evidence.get('write_seconds'),
0048 'said': evidence.get('said') or '',
0049 'probed_at': state.get('probed_at') or '',
0050 'since': state.get('since') or '',
0051 }
0052
0053
0054 def panda_storage_doors(request):
0055 """The doors, their verdicts and their certificates, as the last
0056 cycles left them."""
0057 from monitor_app.models import CachedProduct
0058
0059 row = CachedProduct.objects.filter(key=STATE_KEY).first()
0060 state = (row.value if row else None) or {}
0061 doors = [_row(rse, s) for rse, s in sorted((state.get('doors') or {}).items())]
0062 settings = state.get('settings') or {}
0063 return render(request, 'monitor_app/panda_storage_doors.html', {
0064 'never_run': not state,
0065 'cycle_at': state.get('cycle_at'),
0066 'valid_until': state.get('valid_until'),
0067 'mode': state.get('mode') or DEFAULTS['mode'],
0068 'enabled': bool(state.get('enabled')),
0069 'doors': doors,
0070 'down': state.get('down') or [],
0071 'expiring': state.get('expiring') or [],
0072 'probed': [d for d in doors if d['probed_at']],
0073 'errors': state.get('errors') or [],
0074 'settings': [{'key': f'storage_doors.{k}', 'value': settings.get(k, v)}
0075 for k, v in DEFAULTS.items()],
0076 'active_nav': {'panda_storage_doors': True},
0077 })