From b60544564a9c7e12c8c46cc3398bbc7136dcc489 Mon Sep 17 00:00:00 2001 From: Alex Lowe Date: Tue, 21 Apr 2026 23:31:47 -0400 Subject: [PATCH] test: add failing reproducer for default compat tag warning (issue #454) Adds a test verifying that BuilddBase logs a warning when no custom compatibility_tag is provided. Using the default tag causes all applications to share the same base instance name, leading to LXD DNS name conflicts when multiple projects use LXD simultaneously. Quick fix per issue: log a warning so developers know to set a custom compatibility_tag. Fixes: https://github.com/canonical/craft-providers/issues/454 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/unit/bases/test_ubuntu_buildd.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/unit/bases/test_ubuntu_buildd.py b/tests/unit/bases/test_ubuntu_buildd.py index c33273d0c..c0761a0d1 100644 --- a/tests/unit/bases/test_ubuntu_buildd.py +++ b/tests/unit/bases/test_ubuntu_buildd.py @@ -1934,3 +1934,24 @@ def _raise_error(process) -> None: brief="Failed to update EOL sources.", details="* Command that failed: 'error'\n* Command exit code: 100", ) + + +def test_default_compat_tag_logs_warning(logs): + """BuilddBase must warn when no custom compatibility_tag is provided. + + When two different applications create BuilddBase without a custom + compatibility_tag they both get tag "buildd-base-v7", which means the + resulting base instance has the same LXD name in every project. LXD + then refuses to start the second base instance with: + + Error: Failed start validation for device "eth0": + Instance DNS name "base-instance-buildd-base-v3-..." already used on network + + The quick fix (per the issue) is to log a warning so the developer knows + they should pass a custom compatibility_tag. + + Regression test for https://github.com/canonical/craft-providers/issues/454 + """ + ubuntu.BuilddBase(alias=ubuntu.BuilddBaseAlias.JAMMY) + + assert "compatibility_tag" in logs.warning