← Back to issue list

lxd: use LXD-compatible instance names

View original Github issue

Metadata

Project
craft-providers
Number
#134
Type
pull request
State
merged
Author
mr-cal
Labels
—
Created
Updated
Closed

Current evaluation

Merged PR #134 via commit 9a353a5, adding LXD-compatible instance-name normalization to meet the 63-character limit.

Resolution: closed resolved

Reason: PR #134 was merged into main as commit 9a353a5. It strips forbidden characters, truncates names to 40 characters, and appends a 20-character hash so long LXD instance names are valid.

Evaluated by: mr-cal-bot

No scores available.

Issue body

- [X] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? ----- ### Overview The provided name for a LXD executor object is converted to comply with [LXD naming conventions](https://linuxcontainers.org/lxd/docs/master/instances/) for instances. ### Problem LXC has a 63 character limit on instance names. [This snapcraft commit](https://github.com/snapcore/snapcraft/commit/21cb1ab9ae26cf3322356c190eb555ed05f2d498) adds 18-20 characters to the image name. This is blocking snaps with long names from upgrading to core22. Charmcraft has the [same issue](https://github.com/canonical/charmcraft/issues/629). #### Snapcraft naming convention ``` snapcraft-<project-name>-on-<build-on>-for-<build-for>-<project-path-inode> └ 10 ┘└ 2 - 41 ┘└ 8-11 ┘└ 9-12 ┘└ 10 ┘ ``` Min size: 10 + 2 + 8 + 9 + 10 = 39 Max size: 10 + 41 + 11 + 12 + 10 = 84 #### Charmcraft naming convention ``` charmcraft-<project-name>-<project-path-inode>-<bases-index>-<build-on-index>-<build-for> └ 11 ┘└ 2 - ∞ ┘└ 10 ┘└ 2 ┘└ 2 ┘└ 7 ┘ ``` Min size: 11 + 2 + 10 + 2 + 2 + 7 = 34 Max size: unbound ### Solution `craft-providers` is responsible for complying with each provider’s specific requirements. For LXD, `craft-providers` will: 1. truncate the first 40 characters name 2. remove forbidden characters 3. append a hash of the name ``` <truncated-name>-<hash-of-name> └ 1 - 40 ┘1└ 20 ┘ ``` Min size: 1 + 1 + 20 = 22 Max size: 40 + 1 + 20 = 61 Note: This is an internal change. Applications using `craft-providers` should continue to choose their own unique names for instances. The only restriction is that the name must contain at least one alphanumeric character. LP: #[1981205](https://bugs.launchpad.net/snapcraft/+bug/1981205) (CRAFT-1235)

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Merged PR #134 via commit 9a353a5, adding LXD-compatible instance-name normalization to meet the 63-character limit.
qwen/qwen3.6-35b-a3b — closed resolved Implemented LXD-compatible instance name generation in craft-providers to comply with the 63-character limit. Truncates names, strips forbidden characters, and appends a hash, resolving blocking issues for long snap and charm names.

Update history

Date Change
created

Related work

  • Likely Fixed By: canonical/craft-providers#136 (confidence 92%)

    Follow-up PR #136, commit 1ba69d2, ensured base hostnames were valid, addressing the follow-on limitation noted during review.

Related issues

Issue Project State Summary Similarity
#240 lxd: set image description to instance full name craft-providers merged Merged PR #240 as commit e6af700, setting the LXD image description to the instance's full name so other craft tools can retrieve instance version information.
75%
#1074 ci: fix lxd image name too long charmcraft merged Merged PR #1074 shortened the LXD image name in CI, fixing the "name too long" failure.
71%