Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using default compatibility tag can cause DNS name conflicts #454

Open
mr-cal opened this issue Nov 10, 2023 · 0 comments
Open

Using default compatibility tag can cause DNS name conflicts #454

mr-cal opened this issue Nov 10, 2023 · 0 comments
Labels
Bug Something isn't working

Comments

@mr-cal
Copy link
Collaborator

mr-cal commented Nov 10, 2023

Bug Description

The Base class can accept an optional compatibility_tag. If a compatibility_tag is not provided and craft-providers launches LXD instances for 2 different projects, LXD will fail because the two base instances have identical names.

Source: canonical/craft-application#139

Quick fix

craft-providers should log a warning if a compatibility tag is not provided:

Warning: Compatibilty tag not provided. This may cause a name collision when launching LXD instances.

Long term fix

As part of a major release, the compatibility_tag should be easier to use. It should be required and prepended to the base's compatibility tag.

This simply the usage from:

from craft_providers import bases

base = bases.BuilddBase(compatibility_tag=f"testcraft-{bases.BuildBase.compatibility_tag}", ...)

to:

from craft_providers import bases

base = bases.BuilddBase(compatibility_tag="testcraft", ...)

To Reproduce

#! /usr/bin/env python3

from pathlib import Path
import logging

from craft_providers import bases, lxd

logging.basicConfig(level="DEBUG")

provider_a = lxd.LXDProvider(lxd_project="project1")

provider_a.ensure_provider_is_available()

alias = bases.BuilddBaseAlias.JAMMY
my_base = bases.BuilddBase(alias=alias)

with provider_a.launched_environment(
    project_name = "hello-world",
    project_path = Path().absolute(),
    base_configuration=my_base,
    build_base=alias.value,
    instance_name = "test-instance",
) as instance:
    instance.execute_run(["ls"])


provider_b = lxd.LXDProvider(lxd_project="project2")

provider_b.ensure_provider_is_available()

alias = bases.BuilddBaseAlias.JAMMY
my_base = bases.BuilddBase(alias=alias)

with provider_b.launched_environment(
    project_name = "hello-world",
    project_path = Path().absolute(),
    base_configuration=my_base,
    build_base=alias.value,
    instance_name = "test-instance",
) as instance:
    instance.execute_run(["ls"])

part yaml

No response

Relevant log output

* Command standard error output: b'Error: Failed start validation for device "eth0": Instance DNS name "base-instance-buildd-base-v3-craft-comub-523148486bd0c6cc722c" already used on network\nTry `lxc info --show-log local:base-instance-buildd-base-v3-craft-comub-523148486bd0c6cc722c` for more info\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant