canonical / charms.reactive

Framework for developing charms and relations using the reactive pattern
Apache License 2.0
21 stars 34 forks source link

Reactive charms built with charm version 3.x does not install on bionic (Python >=3.7 is required, 3.6.9 is present) #240

Open valexby opened 1 year ago

valexby commented 1 year ago

The original issue was reported in charmcraft repository, but probably the issue is that reactive losing compatibility with bionic

Building a dummy reactive charm with charm 3.x results in an error in install hook. Example charmcraft.yaml:

type: charm
parts:
  charm:
    source: src
    plugin: reactive
    build-snaps: 
      - charm
bases:
    - build-on:
        - name: ubuntu
          channel: "22.04"
          architectures: ["amd64"]
      run-on:
        - name: ubuntu
          channel: "22.04"
          architectures:
              - amd64
        - name: ubuntu
          channel: "20.04"
          architectures:
              - amd64
        - name: ubuntu
          channel: "18.04"
          architectures:
              - amd64

Installation in bionic environment results in such error log

022-10-06 10:22:33 WARNING unit.graylog/0.install logger.go:60 pip requires Python '>=3.7' but the running Python is 3.6.9
2022-10-06 10:22:33 WARNING unit.graylog/0.install logger.go:60 Traceback (most recent call last):
2022-10-06 10:22:33 WARNING unit.graylog/0.install logger.go:60   File "/var/lib/juju/agents/unit-graylog-0/charm/hooks/install", line 8, in <module>
2022-10-06 10:22:33 WARNING unit.graylog/0.install logger.go:60     basic.bootstrap_charm_deps()
2022-10-06 10:22:33 WARNING unit.graylog/0.install logger.go:60   File "lib/charms/layer/basic.py", line 202, in bootstrap_charm_deps
2022-10-06 10:22:33 WARNING unit.graylog/0.install logger.go:60     _update_if_newer(pip, pre_install_pkgs)
2022-10-06 10:22:33 WARNING unit.graylog/0.install logger.go:60   File "lib/charms/layer/basic.py", line 367, in _update_if_newer
2022-10-06 10:22:33 WARNING unit.graylog/0.install logger.go:60     pkg], env=_get_subprocess_env())
2022-10-06 10:22:33 WARNING unit.graylog/0.install logger.go:60   File "/usr/lib/python3.6/subprocess.py", line 311, in check_call
2022-10-06 10:22:33 WARNING unit.graylog/0.install logger.go:60     raise CalledProcessError(retcode, cmd)
2022-10-06 10:22:33 WARNING unit.graylog/0.install logger.go:60 subprocess.CalledProcessError: Command '['/var/lib/juju/agents/unit-graylog-0/.venv/bin/pip', 'install', '-U', '--no-index', '-f', 'wheelhouse', 'pip']' returned non-zero exit status 1.

The complete error log is available here

For some reason, downgrading charm version to 2.x helps for some reason. Checkout the demo for easy testing of the issue from the original issue

git clone -b charmcraft-bionic-bug https://git.launchpad.net/~esunar/charm-graylog
make charm3 #fails
make charm2 #sucess

Also reproduces for fstab-config charm. Probably other reactive charms are affected too.

esunar commented 1 year ago

What should be the correct way of handling this issue?