← Back to issue list

Builds of charm using reactive plugin produces different config option

View original Github issue

Metadata

Project
charmcraft
Number
#2194
Type
issue
State
closed
Author
chanchiwai-ray
Labels
—
Created
Updated
Closed

Current evaluation

Fixed by merged PR #2245 (commit aa28f0dc): reactive-generated config.yaml is no longer overwritten, preserving options such as snapd_refresh.

Resolution: closed resolved

Reason: PR #2245 merged as commit aa28f0dc and fixed the issue. Packaging now skips Charmcraft-generated config.yaml when a reactive charm has produced one, retaining the complete configuration.

Evaluated by: mr-cal-bot

No scores available.

Issue body

### Bug Description Take https://github.com/canonical/charm-juju-local for example, after updating the `charmcraft.yaml` to the syntax to what `charmcraft 3` supports: ```yaml type: charm parts: charm: source: . plugin: reactive build-snaps: [charm/2.x/stable] platforms: ubuntu@20.04:amd64: ubuntu@22.04:amd64: ``` The produced charm file will have different `config.yaml` than what was build using `charmcraft 2` ```diff diff charmcraft2/config.yaml charmcraft3/config.yaml 1,47c1,8 < # Copyright 2016 Canonical Ltd. < # < # This file is part of the Snap layer for Juju. < # < # Licensed under the Apache License, Version 2.0 (the "License"); < # you may not use this file except in compliance with the License. < # You may obtain a copy of the License at < # < # http://www.apache.org/licenses/LICENSE-2.0 < # < # Unless required by applicable law or agreed to in writing, software < # distributed under the License is distributed on an "AS IS" BASIS, < # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. < # See the License for the specific language governing permissions and < # limitations under the License. < "options": < # snap_proxy and snap_proxy_url have been deprecated for some time. < # If your charm still needs them, add these config items manually < # to your charm's config.yaml. < # snap_proxy: < # description: > < # DEPRECATED. Use snap-http-proxy and snap-https-proxy model configuration settings. < # HTTP/HTTPS web proxy for Snappy to use when accessing the snap store. < # type: string < # default: "" < # snap_proxy_url: < # default: "" < # type: string < # description: > < # DEPRECATED. Use snap-store-proxy model configuration setting. < # The address of a Snap Store Proxy to use for snaps e.g. http://snap-proxy.example.com < "snapd_refresh": < "default": "" < "type": "string" < "description": > < How often snapd handles updates for installed snaps. The default < (an empty string) is 4x per day. Set to "max" to check once per month < based on the charm deployment date. You may also set a custom string as < described in the 'refresh.timer' section here: < https://forum.snapcraft.io/t/system-options/87 < "juju-channel": < "default": "2.9/stable" < "type": "string" < "description": |- < The channel of juju snap to install. Default to 2.9/stable. < Note: This value needs to be set at deployment time. Changes made < post-deployment will not be taken into effect. --- > options: > juju-channel: > default: "2.9/stable" > type: string > description: | > The channel of juju snap to install. Default to 2.9/stable. > Note: This value needs to be set at deployment time. Changes made > post-deployment will not be taken into effect. \ No newline at end of file ``` The difference in the `config.yaml` causes error during the installation of the charm ``` unit-juju-local-0: 2025-02-24 06:55:11 ERROR unit.juju-local/0.juju-log Hook error: Traceback (most recent call last): File "/var/lib/juju/agents/unit-juju-local-0/.venv/lib/python3.10/site-packages/charms/reactive/__init__.py", line 74, in main bus.dispatch(restricted=restricted_mode) File "/var/lib/juju/agents/unit-juju-local-0/.venv/lib/python3.10/site-packages/charms/reactive/bus.py", line 390, in dispatch _invoke(other_handlers) File "/var/lib/juju/agents/unit-juju-local-0/.venv/lib/python3.10/site-packages/charms/reactive/bus.py", line 359, in _invoke handler.invoke() File "/var/lib/juju/agents/unit-juju-local-0/.venv/lib/python3.10/site-packages/charms/reactive/bus.py", line 181, in invoke self._action(*args) File "/var/lib/juju/agents/unit-juju-local-0/charm/reactive/snap.py", line 345, in change_snapd_refresh timer = hookenv.config()["snapd_refresh"] KeyError: 'snapd_refresh' ``` ### To Reproduce `git clone https://github.com/canonical/charm-juju-local` 1. Use charmcraft 2 (2.x/stable) to pack the charm, and unzip the charm file. 2. Update the `charmcraft.yaml` as the following (see below) . Then ,use charmcraft 3 (3.x/stable) to pack the charm, and unzip the charm file. 3. Compare the `config.yaml` between the two builds ### Environment ``` Name Version Rev Tracking Publisher Notes charm 3.0.7 745 3.x/stable canonical✓ classic charmcraft 3.4.2 5977 3.x/stable canonical✓ classic ... ``` ### charmcraft.yaml ```yaml type: charm parts: charm: source: . plugin: reactive build-snaps: [charm/2.x/stable] platforms: ubuntu@20.04:amd64: ubuntu@22.04:amd64: ``` ### Relevant log output ```shell unit-juju-local-0: 2025-02-24 06:55:11 ERROR unit.juju-local/0.juju-log Hook error: Traceback (most recent call last): File "/var/lib/juju/agents/unit-juju-local-0/.venv/lib/python3.10/site-packages/charms/reactive/__init__.py", line 74, in main bus.dispatch(restricted=restricted_mode) File "/var/lib/juju/agents/unit-juju-local-0/.venv/lib/python3.10/site-packages/charms/reactive/bus.py", line 390, in dispatch _invoke(other_handlers) File "/var/lib/juju/agents/unit-juju-local-0/.venv/lib/python3.10/site-packages/charms/reactive/bus.py", line 359, in _invoke handler.invoke() File "/var/lib/juju/agents/unit-juju-local-0/.venv/lib/python3.10/site-packages/charms/reactive/bus.py", line 181, in invoke self._action(*args) File "/var/lib/juju/agents/unit-juju-local-0/charm/reactive/snap.py", line 345, in change_snapd_refresh timer = hookenv.config()["snapd_refresh"] KeyError: 'snapd_refresh' ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Fixed by merged PR #2245 (commit aa28f0dc): reactive-generated config.yaml is no longer overwritten, preserving options such as snapd_refresh.
stealth/space-bunny-alpha — closed resolved Fixed by merged PR #2245 (commit aa28f0dc), which stops the reactive plugin from overwriting config.yaml, preserving options such as snapd_refresh.
qwen3.6-35b-a3b-mtp-q6 — — Closed without resolution. Maintainers acknowledged the charmcraft 3 reactive plugin incorrectly strips deprecated config options, but no fix was implemented.
qwen/qwen3.6-35b-a3b — — Closed without resolution. Internal ticket CRAFT-4206 tracks investigation into why charmcraft 3's reactive plugin modifies config.yaml during the PRIME step, omitting options and breaking deployments.
qwen/qwen3.6-35b-a3b — — Closed without a fix. An internal ticket was created to investigate why charmcraft 3's reactive plugin alters config.yaml, but no resolution was implemented. The report appears abandoned.
qwen3.6-35b-a3b-mtp-q6 — — Abandoned. The charmcraft 3 reactive plugin regression altering config.yaml and causing deployment failures was acknowledged and tracked internally, but no fix was implemented.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: charmcraft#2245 (confidence 100%)

    Merged fix for #2194; commit aa28f0dc prevents overwriting the reactive charm's generated config.yaml.

Related issues

Issue Project State Summary Similarity
#2245 fix(reactive): don't overwrite config.yaml from a reactive charm charmcraft merged Merged PR #2245 (commit aa28f0dc, CRAFT-4206) stops the package service from overwriting a config.yaml generated by a reactive charm, fixing #2194.
73%
#863 reactive_plugin: Support arguments to charm build command charmcraft merged Merged in charmcraft PR #863 via commit a5f200b1, adding reactive-charm-build-arguments so the reactive plugin can pass options to charm build; fixes #809.
72%
#924 reactive plugin: call `charm build` with `-v` charmcraft closed Fixed by merged PR #2021 (commit 7129d57e): the reactive plugin adds --verbose to charm build unless an explicit verbosity or log level is supplied.
72%
#809 Reactive plugin doesn't allow for other `charm` cli arguments. charmcraft closed Resolved by merged PR #863 (merge commit a5f200b1): reactive builds can now pass charm build options such as --layer-index via reactive-charm-build-arguments.
72%
#1816 Reactive charm built with charmcraft 3.x is missing options from the included layers and is broken charmcraft open Reactive layer options were lost because Charmcraft 3.x overwrote charm-tools' config.yaml; commit aa28f0dc and PR #2245 now preserve the generated configuration.
70%