lab7: BROKER_URL из окружения, Redis operator для регрессии ACL, исправления тестов, no-new-privileges tempo-init; перенос исправлений lab6

This commit is contained in:
2026-11-12 14:19:15 +03:00
parent b5b55fda89
commit 1c453e9f0a
16 changed files with 104 additions and 33 deletions
+8 -1
View File
@@ -159,12 +159,19 @@ def ensure_creds():
def write_backend_files(creds):
acl = OP / 'redis_users.acl'
h = hashlib.sha256(creds['api']['redis_password'].encode()).hexdigest()
# Операторская учётка Redis (администрирование, регрессионный тест ACL); приложениям не выдаётся.
opf = OP / 'redis_operator_password'
if not opf.exists():
opf.write_text(rnd.token_hex(24))
os.chmod(opf, 0o600)
ho = hashlib.sha256(opf.read_text().strip().encode()).hexdigest()
# default отключён; api — только свои ключи и нужные команды; healthcheck — только PING.
acl.write_text(
'user default off\n'
'user healthcheck on nopass resetkeys resetchannels -@all +ping +hello +auth\n'
'user api on #%s resetchannels ~session:* ~messages:* ~rl:* -@all +@connection '
'+get +set +del +ttl +scan +incr +expire +multi +exec +discard +ping\n' % h)
'+get +set +del +ttl +scan +incr +expire +multi +exec +discard +ping\n'
'user operator on #%s ~* &* +@all\n' % (h, ho))
s3 = OP / 's3_users.txt'
s3.write_text(''.join('%s %s %s\n' % (s, creds[s]['s3_access_key'], creds[s]['s3_secret_key']) for s in SERVICES))
for p in (acl, s3):
+4 -2
View File
@@ -31,7 +31,7 @@ def row(title):
y += 1
def ts(title, targets, unit, x, w=8, h=8, desc='', stack=False, minv=None):
def ts(title, targets, unit, x, w=8, h=8, desc='', stack=False, minv=None, maxv=None):
p = {'type': 'timeseries', 'title': title, 'id': nid(), 'datasource': PROM, 'description': desc,
'gridPos': {'h': h, 'w': w, 'x': x, 'y': y},
'fieldConfig': {'defaults': {'unit': unit, 'custom': {'fillOpacity': 10, 'showPoints': 'never',
@@ -42,6 +42,8 @@ def ts(title, targets, unit, x, w=8, h=8, desc='', stack=False, minv=None):
'exemplar': True} for i, (e, l) in enumerate(targets)]}
if minv is not None:
p['fieldConfig']['defaults']['min'] = minv
if maxv is not None:
p['fieldConfig']['defaults']['max'] = maxv
panels.append(p)
@@ -118,7 +120,7 @@ ts('RabbitMQ: сообщения в очередях',
'none', 16)
y += 8
ts('Saturation worker (busy / capacity)',
[('sum(messenger_worker_busy) / sum(messenger_worker_capacity)', 'занято слотов')], 'percentunit', 0, minv=0)
[('sum(messenger_worker_busy) / sum(messenger_worker_capacity)', 'занято слотов')], 'percentunit', 0, minv=0, maxv=1)
ts('Publish outbox → broker (confirm) p95',
[(q('messenger_outbox_publish_duration_seconds_bucket')(0.95), 'p95'),
('sum(rate(messenger_outbox_published_total[$__rate_interval]))', 'сообщений/с')], 's', 8)