fix(stage): retain allowlisted bootstrap API failure status
Stage author bootstrap (dedicated repair) / bootstrap (push) Failing after 48s
Stage author bootstrap (dedicated repair) / bootstrap (push) Failing after 48s
This commit is contained in:
1 parent
5c93517b9e
commit
a0d588ba12
2 files changed
+16
-4
No files matched your search
@@ -26,7 +26,12 @@ def check_image(d, image, sha):
|
||||
|
||||
def api(d, backend, token):
|
||||
# No retry: a lost response can follow a committed transaction.
|
||||
result = json.loads(d.run(['exec', '-i', backend, 'node', '-e', API_JS], token, timeout=40))
|
||||
try:
|
||||
result = json.loads(d.run(['exec', '-i', backend, 'node', '-e', API_JS], token, timeout=40))
|
||||
except subprocess.CalledProcessError as error:
|
||||
diagnostic = (error.stderr or b'').decode(errors='replace')
|
||||
match = re.search(r'BOOTSTRAP_API_(?:STATUS_[0-9]{3}|CONTRACT|TRANSPORT)', diagnostic)
|
||||
raise ValueError(match.group(0) if match else 'Bootstrap API process failed') from None
|
||||
if {a.get('id') for a in result.get('authors', [])} != AUTHOR_IDS:
|
||||
raise ValueError('API returned unexpected author identities')
|
||||
return result
|
||||
@@ -127,9 +132,9 @@ def readiness(d, cid):
|
||||
API_JS = r'''const fs=require('fs'); const token=fs.readFileSync(0,'utf8').trim();
|
||||
(async()=>{let r=await fetch('http://127.0.0.1:39071/api/admin/users/stage-author-restoration',{
|
||||
method:'POST',headers:{Authorization:'Bearer '+token},signal:AbortSignal.timeout(30000)});
|
||||
if(!r.ok)throw Error('API status '+r.status);let x=await r.json();
|
||||
if(x.success!==true||x.totalConfigured!==5||x.restoredCount+x.existingCount!==5)throw Error('API contract');
|
||||
process.stdout.write(JSON.stringify(x));})().catch(()=>{process.exit(1)});'''
|
||||
if(!r.ok){console.error('BOOTSTRAP_API_STATUS_'+r.status);process.exit(1)}let x=await r.json();
|
||||
if(x.success!==true||x.totalConfigured!==5||x.restoredCount+x.existingCount!==5){console.error('BOOTSTRAP_API_CONTRACT');process.exit(1)}
|
||||
process.stdout.write(JSON.stringify(x));})().catch(()=>{console.error('BOOTSTRAP_API_TRANSPORT');process.exit(1)});'''
|
||||
|
||||
def rehearse(d, backup, sql, backend_image, env_file, token, owned, evidence):
|
||||
def clone():
|
||||
|
||||
@@ -96,6 +96,13 @@ class WorkflowTests(unittest.TestCase):
|
||||
|
||||
|
||||
class MaintenanceTests(unittest.TestCase):
|
||||
def test_api_failure_diagnostic_never_leaks_stderr(self):
|
||||
class D:
|
||||
def run(self, *args, **kwargs):
|
||||
raise subprocess.CalledProcessError(1, ['fixture'], stderr=b'private fixture BOOTSTRAP_API_STATUS_403 private fixture')
|
||||
with self.assertRaisesRegex(ValueError, '^BOOTSTRAP_API_STATUS_403$'):
|
||||
ci.op.api(D(), 'fixture', b'fixture')
|
||||
|
||||
def test_snapshot_stream_auth_matches_existing_configuration(self):
|
||||
import os
|
||||
text = (HERE / 'operation.py').read_text()
|
||||
|
||||
Reference in new issue
Block a user