Name the overlapping mount paths and fix new OCI review translations

This commit is contained in:
MacRimi
2026-10-18 11:49:48 +02:00
parent 2aa6e0ba44
commit 9861a85ccd
5 changed files with 30 additions and 16 deletions
+4 -3
View File
@@ -571,9 +571,10 @@ def preflight(record, candidate, config, coordinated=None, in_place=False, basel
target = host_mounts.valid_path(mount['container_path'])
if mount['type'] == 'host-bind' and mount['source'] in declared and mount.get('read_only'):
continue
if (any(target == p or target.startswith(p.rstrip('/') + '/')
or p.startswith(target.rstrip('/') + '/') for p in paths)):
raise ValueError(translate('Mount paths must not overlap'))
other = next((p for p in paths if target == p or target.startswith(p.rstrip('/') + '/')
or p.startswith(target.rstrip('/') + '/')), None)
if other:
raise ValueError(f"{translate('Mount paths must not overlap')}: {target} - {other}")
if mount['type'] == 'managed-volume':
if mount.get('backup') is not True or not isinstance(mount.get('size_gb'), int) or mount['size_gb'] < 1:
raise ValueError(translate('Managed disks must have backup enabled and a valid size'))
+13
View File
@@ -1,4 +1,5 @@
"""Regression tests for explicit adoption of external OCI resources."""
import copy
import json
from pathlib import Path
import sys
@@ -216,5 +217,17 @@ class EnvironmentAdoptionTests(unittest.TestCase):
reconcile.propose(record, config)
class OverlapMessageTests(unittest.TestCase):
def test_the_refusal_names_both_paths(self):
from test_modify_review import installation
saved, config = installation()
candidate = copy.deepcopy(saved)
volume = {'type': 'managed-volume', 'source': 'local-lvm', 'size_gb': 1, 'backup': True, 'read_only': False}
candidate['deployment']['mounts'] = [dict(volume, container_path='/source'),
dict(volume, container_path='/source/archivos')]
with self.assertRaisesRegex(ValueError, '/source/archivos - /source$'):
reconcile.transaction.preflight(saved, candidate, config)
if __name__ == '__main__':
unittest.main()