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

Builds of charm using reactive plugin produces different config option #2194

Open
chanchiwai-ray opened this issue Feb 25, 2025 · 2 comments
Labels
Bug Something isn't working triaged

Comments

@chanchiwai-ray
Copy link

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:

type: charm
parts:
  charm:
    source: .
    plugin: reactive
    build-snaps: [charm/2.x/stable]
platforms:
  [email protected]:amd64:
  [email protected]:amd64:

The produced charm file will have different config.yaml than what was build using charmcraft 2

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

type: charm
parts:
  charm:
    source: .
    plugin: reactive
    build-snaps: [charm/2.x/stable]
platforms:
  [email protected]:amd64:
  [email protected]:amd64:

Relevant log output

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'
@lengau
Copy link
Collaborator

lengau commented Feb 25, 2025

Thanks for the report! I think I know why this is occurring, but actually implementing the fix is going to require some research.

@lengau lengau added the triaged label Feb 25, 2025
Copy link

Thank you for reporting your feedback to us!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-4206.

This message was autogenerated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working triaged
Projects
None yet
Development

No branches or pull requests

2 participants