← Back to issue list

Build fails when multiple run-on are specified

View original Github issue

Metadata

Project
charmcraft
Number
#2133
Type
issue
State
closed
Author
seb4stien
Labels
—
Created
Updated
Closed

Current evaluation

Fixed in Charmcraft 3.4.3 via craft-providers PR #722, which removes underscores from hostnames generated for multiple run-on targets.

Resolution: closed resolved

Reason: Maintainer lengau confirmed that the failure was fixed in 3.4.3. The linked fix in canonical/craft-providers#722 sanitizes generated instance hostnames.

Evaluated by: mr-cal-bot

No scores available.

Issue body

### Bug Description The `charmcraft build` command fails when charmcraft.yaml contains the following configuration: ```yaml bases: - build-on: - name: ubuntu channel: "22.04" run-on: - name: ubuntu channel: "22.04" - name: "ubuntu" channel: "20.04" ``` In the logs we can see that charmcraft is generating a hostname that contains understores: ``` 2025-01-31 15:16:50.027 Setting charmcraft to be injected from the host into the build environment because it is running as a snap. 2025-01-31 15:16:50.027 Preparing managed instance 'charmcraft-digest-squid-auth-helper-ubuntu-22.04-amd64_ubuntu-20.04-amd64-5603827' 2025-01-31 15:16:50.031 Using hostname 'charmcraft-digest-squid-auth-helper-ubuntu-2204-amd64_ubuntu-2' ``` This generates an error as '_' are not valid characters for the `hostname` command: ``` 2025-01-31 15:17:01.013 Executing in container: lxc --project charmcraft exec local:charmcraft-digest-squid-auth-helper-ubun-5e15c5547ad997b04c08 -- env CRAFT_MANAGED_MODE=1 CHARMCRAFT_MANAG ED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical hostname -F /etc/hostname 2025-01-31 15:17:01.383 Failed to set hostname. ``` A proposal to solve the issue here: https://github.com/canonical/craft-providers/pull/722 ### To Reproduce Create a charm with multiple "run-on" destinations (see charmcraft.yaml) and try to build it. ### Environment Building on Ubuntu 24.04 ### charmcraft.yaml ```yaml bases: - build-on: - name: ubuntu channel: "22.04" run-on: - name: ubuntu channel: "22.04" - name: "ubuntu" channel: "20.04" ``` ### Relevant log output ```shell 2025-01-31 15:16:50.027 Setting charmcraft to be injected from the host into the build environment because it is running as a snap. 2025-01-31 15:16:50.027 Preparing managed instance 'charmcraft-digest-squid-auth-helper-ubuntu-22.04-amd64_ubuntu-20.04-amd64-5603827' 2025-01-31 15:16:50.031 Using hostname 'charmcraft-digest-squid-auth-helper-ubuntu-2204-amd64_ubuntu-2' ... 2025-01-31 15:17:01.013 Executing in container: lxc --project charmcraft exec local:charmcraft-digest-squid-auth-helper-ubun-5e15c5547ad997b04c08 -- env CRAFT_MANAGED_MODE=1 CHARMCRAFT_MANAG ED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical hostname -F /etc/hostname 2025-01-31 15:17:01.383 Failed to set hostname. ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Fixed in Charmcraft 3.4.3 via craft-providers PR #722, which removes underscores from hostnames generated for multiple run-on targets.
stealth/space-bunny-alpha — closed resolved Fixed in Charmcraft 3.4.3 with craft-providers PR #722, removing underscores from generated hostnames when multiple run-on targets are specified.
stealth/space-bunny-alpha — closed resolved Fixed in Charmcraft 3.4.3: craft-providers PR #722 removed underscores from generated hostnames, so builds with multiple run-on targets no longer fail hostname validation.
qwen3.6-35b-a3b-mtp-q6 — — Build failures from invalid underscores in hostnames when using multiple run-on targets were resolved. The issue was fixed in version 3.4.3 by sanitizing generated instance names to meet hostname requirements.
qwen/qwen3.6-35b-a3b — — Fixed in version 3.4.3. Build failures caused by invalid underscores in generated hostnames when multiple run-on destinations are specified have been resolved.
qwen/qwen3.6-35b-a3b — — Fixed in version 3.4.3. The build failure caused by invalid underscores in generated hostnames when multiple run-on destinations are specified has been resolved via craft-providers PR #722.
qwen3.6-35b-a3b-mtp-q6 — — Fixed in version 3.4.3. The build failure caused by invalid underscores in generated hostnames when multiple run-on destinations are specified has been resolved by updating the hostname generation logic.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/craft-providers#722 (confidence 99%)

    The proposed provider change removes underscores from generated hostnames when multiple run-on targets are used.

Related issues

Issue Project State Summary Similarity
#2158 "Invalid hostname" error when packing charm that runs on multiple bases charmcraft closed The invalid-hostname failure was fixed by canonical/craft-providers#722 (commit cabdba5), removing underscores from generated hostnames. The fix shipped through Charmcraft; Microceph's network error was Docker-related.
71%