fix(deploy): keep broker credentials active during update rollback
Preserve broker environment and the active keyring mount when rolling application images back. Guard with update staging tests: 54 passed. No runtime services changed.
This commit is contained in:
@@ -390,8 +390,12 @@ def prepare_update(args):
|
||||
if mount['target']=='/run/hainuo-credentials/keyring.json':
|
||||
mount['source']=str(output/'credential-keyring.json')
|
||||
write_json(output/'compose.broker.json',overlay)
|
||||
write_json(output/'compose.rollback.json',{'services':{name:{'image':roles[name]['image']}
|
||||
for name in ('connector','router','longconn','enrollment-signer')}})
|
||||
rollback=json.loads(json.dumps(overlay))
|
||||
for name in ('connector','router'):
|
||||
rollback['services'][name]['image']=roles[name]['image']
|
||||
# An update rollback must retain broker env/key mounts, never silently
|
||||
# revert to the original legacy credential owner from base Compose files.
|
||||
write_json(output/'compose.rollback.json',rollback)
|
||||
payload=output/'build';payload.mkdir(mode=0o700)
|
||||
for path in (source/'relay').rglob('*'):
|
||||
if path.is_symlink():raise DeployError('symlink in update source')
|
||||
|
||||
@@ -533,6 +533,10 @@ def test_prepare_update_preserves_key_material_and_parent_plan_without_restart(s
|
||||
overlay=json.loads((output/'compose.broker.json').read_text())
|
||||
old=json.loads((root/'compose.broker.json').read_text())
|
||||
assert overlay['services']['connector']['environment']==old['services']['connector']['environment']
|
||||
rollback=json.loads((output/'compose.rollback.json').read_text())
|
||||
assert rollback['services']['connector']['environment']==old['services']['connector']['environment']
|
||||
assert rollback['services']['connector']['volumes']==overlay['services']['connector']['volumes']
|
||||
assert rollback['services']['connector']['image']==image
|
||||
assert not any('up' in call or 'build' in call or 'tag' in call for call in scenario['calls'])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user