lab7: live stand integration fixes and verified evidence
This commit is contained in:
+35
-10
@@ -378,25 +378,50 @@ def targeted_job(c, alice, chat, obs_client):
|
||||
|
||||
|
||||
def correlate_fault(client_args, obs_client, kind):
|
||||
"""Trigger a real worker retry (transient S3 outage) or terminal failure
|
||||
(SHA-256 source mismatch) without requiring Redis access in the isolated
|
||||
lab7 worker container."""
|
||||
c, alice, chat = new_context(client_args.base_url, client_args.ca_file)
|
||||
obs_client.require_no_foreign_faults()
|
||||
key = None
|
||||
s3_stopped = False
|
||||
try:
|
||||
att, rid, job_id, version = targeted_job(c, alice, chat, obs_client)
|
||||
key = 'fault:worker.before_side_effect:%s:%s' % (att['id'], version)
|
||||
stand.set_fault(key, kind)
|
||||
start_worker()
|
||||
if kind == 'transient':
|
||||
stand.compose('stop', 's3')
|
||||
s3_stopped = True
|
||||
start_worker()
|
||||
|
||||
def retried():
|
||||
job = status_of(att['id'])['jobs'][0]
|
||||
return job['attempt'] >= 2 or job['last_error_code']
|
||||
res = stand.compose(
|
||||
'exec', '-T', 'postgres', 'psql',
|
||||
'-h', '/var/run/postgresql', '-U', 'postgres', '-d', 'messenger',
|
||||
'-At', '-c',
|
||||
"SELECT attempt, coalesce(last_error_code, '') FROM attachment_jobs "
|
||||
"WHERE attachment_id = '" + att['id'] + "' LIMIT 1",
|
||||
)
|
||||
line = res.stdout.strip()
|
||||
if '|' not in line:
|
||||
return False
|
||||
att_num, err_code = line.split('|', 1)
|
||||
return (att_num.isdigit() and int(att_num) >= 2) or bool(err_code)
|
||||
|
||||
stand.wait_for(retried, 90, 'first retry')
|
||||
stand.clear_fault(key)
|
||||
key = None
|
||||
stand.compose('up', '-d', '--no-deps', '--wait', 's3')
|
||||
s3_stopped = False
|
||||
stand.wait_ready(c, alice, att['id'], timeout=120)
|
||||
else:
|
||||
stand.compose(
|
||||
'exec', '-T', 'postgres', 'psql',
|
||||
'-h', '/var/run/postgresql', '-U', 'postgres', '-d', 'messenger',
|
||||
'-v', 'ON_ERROR_STOP=1', '-c',
|
||||
"UPDATE attachments SET sha256 = '" + ('0' * 64) +
|
||||
"' WHERE id = '" + att['id'] + "'",
|
||||
)
|
||||
start_worker()
|
||||
|
||||
def failed():
|
||||
return status_of(att['id'])['jobs'][0]['status'] == 'failed'
|
||||
|
||||
stand.wait_for(failed, 90, 'terminal failed job')
|
||||
meta = stand.wait_ready(c, alice, att['id'], allow_failed=True)
|
||||
if meta['status'] != 'failed':
|
||||
@@ -434,8 +459,8 @@ def correlate_fault(client_args, obs_client, kind):
|
||||
('status', 'attempt', 'last_error_code')},
|
||||
'final_attachment_status': final['attachment']['status']}
|
||||
finally:
|
||||
if key:
|
||||
stand.clear_fault(key)
|
||||
if s3_stopped:
|
||||
stand.compose('up', '-d', '--no-deps', '--wait', 's3')
|
||||
start_worker()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user