Console 3.1.31: persist host migration when upgrading an old bootstrap

This commit is contained in:
Andrei Smaliak 2026-10-29 16:12:15 +01:00
parent 54ea6e3133
commit 52e43b9476
5 changed files with 44 additions and 3 deletions

View File

@ -0,0 +1,10 @@
# Console 3.1.31 — persist migration from old installed bootstrap
- Bench upgrade through the pre-migration Console revealed that the old running
bootstrap writes its old host into snapshot metadata and credentials before
invoking the new activator. Requests already normalize it, but stored values
must also migrate.
- The new activator now persists the canonical host in both source metadata and
credentials as well as the derived APT and stage-update configuration.
- Preserve credentials and their 0600 permissions; never expose them in logs.
- Includes the complete Console 3.1.30 module audit and new-domain-only retries.

View File

@ -407,8 +407,14 @@ def activate(root):
source = json.loads((root / '.iomatex-source.json').read_text()) source = json.loads((root / '.iomatex-source.json').read_text())
repo_name('https://' + git_host(source.get('host', HOST)) + '/' + source['repo']) repo_name('https://' + git_host(source.get('host', HOST)) + '/' + source['repo'])
raw_endpoint('probe', source['commit']) raw_endpoint('probe', source['commit'])
auth_from_env() # fail before modifying APT if reboot credentials are missing auth = auth_from_env() # fail before modifying APT if reboot credentials are missing
auth['host'] = git_host(auth.get('host', HOST))
text, objects = catalog(root) text, objects = catalog(root)
# An older bootstrap invokes this NEW activator but may have persisted its old host.
# Migrate both durable inputs here, not only the derived APT/stage configuration.
source['host'] = HOST
write_json(root / '.iomatex-source.json', source)
write_json(AUTH, auth, 0o600)
STATE.mkdir(parents=True, exist_ok=True) STATE.mkdir(parents=True, exist_ok=True)
(STATE / 'Packages').write_text(text) (STATE / 'Packages').write_text(text)
(STATE / 'Packages.gz').write_bytes(gzip.compress(text.encode(), mtime=0)) (STATE / 'Packages.gz').write_bytes(gzip.compress(text.encode(), mtime=0))

View File

@ -31,6 +31,31 @@ class DeliveryTest(unittest.TestCase):
d.download_object(config, 'debian/a.deb', Path(folder)/'a.deb', {'username': 'u', 'password': 'p'}) d.download_object(config, 'debian/a.deb', Path(folder)/'a.deb', {'username': 'u', 'password': 'p'})
self.assertEqual('git.iomatex.com', request.call_args.args[2]['host']) self.assertEqual('git.iomatex.com', request.call_args.args[2]['host'])
def test_new_activator_migrates_old_bootstrap_persisted_inputs(self):
with tempfile.TemporaryDirectory() as folder:
base = Path(folder)
root = base/'snapshot'
(root/'offline').mkdir(parents=True)
(root/'offline/git_delivery.py').write_text('# delivery owner')
(root/'.iomatex-source.json').write_text(json.dumps({
'host':'git.it-screen.com','repo':'An-J/Iomatex_OS','commit':'a'*40}))
(base/'etc/apt/apt.conf.d').mkdir(parents=True)
(base/'usr/lib/apt/methods').mkdir(parents=True)
auth = base/'auth.json'
def mapped(value):
return base/str(value).lstrip('/') if str(value).startswith(('/etc/apt','/usr/')) else Path(value)
with patch.object(d, 'platform_check'), patch.object(d, 'catalog', return_value=('',{})), \
patch.object(d, 'auth_from_env', return_value={'username':'u','password':'p','host':'git.it-screen.com'}), \
patch.object(d, 'STATE', base/'state'), patch.object(d, 'AUTH', auth), \
patch.object(d, 'CACHE', base/'cache'), patch.object(d, 'Path', side_effect=mapped), \
patch.object(d, 'cleanup'):
d.activate(root)
for path in [auth, root/'.iomatex-source.json', base/'state/source.json']:
self.assertEqual('git.iomatex.com', json.loads(path.read_text())['host'])
self.assertEqual('p', json.loads(auth.read_text())['password'])
self.assertEqual(0o600, auth.stat().st_mode & 0o777)
self.assertIn('iomatex://git.iomatex.com/', (base/'etc/apt/iomatex-offline.list').read_text())
def test_payloads_excluded_from_edge_snapshot(self): def test_payloads_excluded_from_edge_snapshot(self):
for name in ['third_party/debian/bullseye-arm64/repo/a.deb', 'third_party/zigbee2mqtt/z.tar.gz', 'stage_itscreen/itscreen']: for name in ['third_party/debian/bullseye-arm64/repo/a.deb', 'third_party/zigbee2mqtt/z.tar.gz', 'stage_itscreen/itscreen']:
self.assertTrue(d.is_payload(name)) self.assertTrue(d.is_payload(name))

View File

@ -14,7 +14,7 @@
"version": "1.0.1" "version": "1.0.1"
}, },
"stage_ui": { "stage_ui": {
"version": "3.1.30" "version": "3.1.31"
}, },
"stage_avahi": { "stage_avahi": {
"version": "1.0.0" "version": "1.0.0"

View File

@ -1,3 +1,3 @@
{ {
"version": "3.1.30" "version": "3.1.31"
} }