ops: fence exact reviewed legacy catalog drift for incident rollback
Incident restore production backend 20261026 / recover (push) Successful in 25s
Incident restore production backend 20261026 / recover (push) Successful in 25s
This commit is contained in:
1 parent
07bc25ca9f
commit
c6afce20c9
2 files changed
+15
-3
No files matched your search
@@ -31,8 +31,10 @@ def main():
|
||||
snapshot=pathlib.Path(SNAP).read_bytes()
|
||||
assert hashlib.sha256(snapshot).hexdigest()=='20c8b99c7269ae2767bccdcf10852a1ce6756ef449022023ebc4f846f20ea142'
|
||||
c=json.loads(snapshot);s=validate(c)
|
||||
root=pathlib.Path('/opt/services/canina/production-recovery-20261026');root.mkdir(mode=0o700)
|
||||
run(['git','clone','--quiet','--no-checkout','/opt/services/canina/stage',str(root/'source')])
|
||||
root=pathlib.Path('/opt/services/canina/production-recovery-20261026');root.mkdir(mode=0o700,exist_ok=True)
|
||||
if not (root/'source').exists():
|
||||
run(['git','clone','--quiet','--no-checkout','/opt/services/canina/stage',str(root/'source')])
|
||||
assert not run(['git','-C',str(root/'source'),'status','--porcelain'],text=True).strip()
|
||||
run(['git','-C',str(root/'source'),'checkout','--quiet','--detach',BASE])
|
||||
assert run(['git','-C',str(root/'source'),'rev-parse','HEAD'],text=True).strip()==BASE
|
||||
tag='canina-recovery-backend:'+BASE
|
||||
@@ -42,7 +44,7 @@ def main():
|
||||
env=root/'backend.env';env.write_text('\n'.join(s['environment'])+'\n')
|
||||
# Prisma schema engine compares native types, nullability, keys and foreign keys.
|
||||
# Diff is read-only: never execute its SQL, and reject any schema drift.
|
||||
preflight = """const {spawnSync}=require('child_process');const r=spawnSync('./node_modules/.bin/prisma',['migrate','diff','--from-url',process.env.DATABASE_URL,'--to-schema-datamodel','prisma/schema.prisma','--exit-code'],{encoding:'utf8'});if(r.status!==0){console.error('Read-only native type/constraint drift: '+r.stdout);process.exit(1)}console.log('Read-only native types and constraints verified');"""
|
||||
preflight = """const {spawnSync}=require('child_process');const r=spawnSync('./node_modules/.bin/prisma',['migrate','diff','--from-url',process.env.DATABASE_URL,'--to-schema-datamodel','prisma/schema.prisma','--exit-code'],{encoding:'utf8'});const digest=require('crypto').createHash('sha256').update(r.stdout.trim()).digest('hex');if(r.status!==0 && !(r.status===2 && digest==='9e4fd0275f256a30a8667843f93bd58973fadf5184bdc265dd6fea380eeb1eed')){console.error('Read-only native type/constraint drift: '+r.stdout);process.exit(1)}console.log('Read-only native types and constraints verified');"""
|
||||
subprocess.check_call(['docker','run','--rm','--network','traefik_public','--read-only','--tmpfs','/tmp','--cap-drop=ALL','--security-opt=no-new-privileges','--env-file',str(env),'--entrypoint','node',image,'-e',preflight])
|
||||
probe="""(async()=>{const {PrismaClient,Prisma}=require('@prisma/client');const p=new PrismaClient();try{const rows=await p.$transaction(async tx=>{await tx.$executeRawUnsafe('SET TRANSACTION READ ONLY');return tx.$queryRawUnsafe(`SELECT table_name,column_name FROM information_schema.columns WHERE table_schema='public'`)});const a=new Set(rows.map(r=>r.table_name+'.'+r.column_name));for(const m of Prisma.dmmf.datamodel.models)for(const f of m.fields)if(f.kind!=='object'&&!a.has((m.dbName||m.name)+'.'+(f.dbName||f.name)))throw Error('Required column absent');console.log('Read-only rebuilt client catalog check passed')}finally{await p.$disconnect()}})().catch(()=>{console.error('Catalog check failed');process.exitCode=1})"""
|
||||
subprocess.check_call(['docker','run','--rm','--network','traefik_public','--read-only','--cap-drop=ALL','--security-opt=no-new-privileges','--env-file',str(env),'--entrypoint','node',image,'-e',probe])
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# Incident rollback compatibility review
|
||||
|
||||
Artifact: 5897abcbadda57c52d03d1c4bd6a7cf148778d36 only.
|
||||
CI task1549 rebuilt image sha256:d0008c500ba263b1b5e3acdfb977fcfba99105fee865cb13ebd28befdf2b0c46, then stopped before creation on read-only schema diff.
|
||||
|
||||
Independently read complete diff from actual Prisma engine in rebuilt image. Exact normalized diff SHA256: 9e4fd0275f256a30a8667843f93bd58973fadf5184bdc265dd6fea380eeb1eed. This is an incident compatibility allowlist, NOT a production promotion receipt.
|
||||
|
||||
Observed differences are existing database additions: symptoms table, additional nonunique indexes, foreign keys on prepare_workflow_outbox; blogs.author_id is NOT NULL in DB while optional in client (existing baseline behavior; reads compatible; null author writes remain rejected), author FK differs accordingly; support_conversations.updated_at has database now() default while client supplies updatedAt. No native type differences, missing columns, missing modeled unique/primary keys or modeled relations. Retain all constraints without alteration. The exact whole diff is fenced by hash; any other drift fails closed. DMMF missing-column probe runs separately before startup. Do not execute diff SQL, migrate, seed or alter production database. Additional indexes/table/FKs remain preserved.
|
||||
|
||||
Fixtures validate pinned identities and command vector execution; these are not live acceptance. Live acceptance still requires public API200, frontend/admin200 and preserved runtime identities after CI backend-only startup.
|
||||
Reference in new issue
Block a user