canonical / charmcraft

Collaborate, build and publish charmed operators for Kubernetes, Linux and Windows.
Apache License 2.0
66 stars 72 forks source link

Unable to build a charm that deploys on xenial #589

Closed mthaddon closed 3 years ago

mthaddon commented 3 years ago

I noticed that the ubuntu charm doesn't have a charmcraft.yaml file yet. So I added one as follows and built locally:

type: charm
bases:
  - build-on:
    - name: "ubuntu"
      channel: "20.04"
    run-on:
    - name: "ubuntu"
      channel: "16.04"
    - name: "ubuntu"
      channel: "18.04"
    - name: "ubuntu"
      channel: "20.04"
    - name: "ubuntu"
      channel: "21.04"
    - name: "ubuntu"
      channel: "22.04"

This failed to deploy on xenial:

unit-ubuntu-0: 10:52:07 INFO juju.worker.uniter awaiting error resolution for "install" hook
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install Traceback (most recent call last):
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install   File "./src/charm.py", line 7, in <module>
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install     from ops.charm import CharmBase
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install   File "/var/lib/juju/agents/unit-ubuntu-0/charm/venv/ops/__init__.py", line 43, in <module>
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install     from . import charm  # noqa: F401 (imported but unused)
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install   File "/var/lib/juju/agents/unit-ubuntu-0/charm/venv/ops/charm.py", line 22, in <module>
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install     from ops import model
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install   File "/var/lib/juju/agents/unit-ubuntu-0/charm/venv/ops/model.py", line 1017, in <module>
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install     class Container:
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install   File "/var/lib/juju/agents/unit-ubuntu-0/charm/venv/ops/model.py", line 1053, in Container
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install     combine: bool = False):
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install   File "/usr/lib/python3.5/typing.py", line 552, in __getitem__
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install     dict(self.__dict__), parameters, _root=True)
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install   File "/usr/lib/python3.5/typing.py", line 512, in __new__
unit-ubuntu-0: 10:52:08 WARNING unit.ubuntu/0.install     for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
unit-ubuntu-0: 10:52:18 INFO juju.worker.uniter awaiting error resolution for "install" hook
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install Traceback (most recent call last):
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install   File "./src/charm.py", line 7, in <module>
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install     from ops.charm import CharmBase
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install   File "/var/lib/juju/agents/unit-ubuntu-0/charm/venv/ops/__init__.py", line 43, in <module>
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install     from . import charm  # noqa: F401 (imported but unused)
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install   File "/var/lib/juju/agents/unit-ubuntu-0/charm/venv/ops/charm.py", line 22, in <module>
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install     from ops import model
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install   File "/var/lib/juju/agents/unit-ubuntu-0/charm/venv/ops/model.py", line 1017, in <module>
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install     class Container:
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install   File "/var/lib/juju/agents/unit-ubuntu-0/charm/venv/ops/model.py", line 1053, in Container
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install     combine: bool = False):
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install   File "/usr/lib/python3.5/typing.py", line 552, in __getitem__
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install     dict(self.__dict__), parameters, _root=True)
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install   File "/usr/lib/python3.5/typing.py", line 512, in __new__
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install     for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install   File "/usr/lib/python3.5/typing.py", line 512, in <genexpr>
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install     for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install   File "/usr/lib/python3.5/typing.py", line 190, in __subclasscheck__
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install     self._eval_type(globalns, localns)
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install   File "/usr/lib/python3.5/typing.py", line 177, in _eval_type
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install     eval(self.__forward_code__, globalns, localns),
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install   File "<string>", line 1, in <module>
unit-ubuntu-0: 10:52:18 WARNING unit.ubuntu/0.install AttributeError: 'property' object has no attribute 'Layer'
unit-ubuntu-0: 10:52:18 ERROR juju.worker.uniter.operation hook "install" (via hook dispatching script: dispatch) failed: exit status 1

I tried changing the build-on value to 18.04 got the same error when deploying the charm on xenial. I tried changing the build-on value to 16.04 but I get the error Skipping 'bases[0].build-on[0]': channel '16.04' is not yet supported (must be '18.04' or '20.04').

It seems to me like it's not currently possible to build a charm using charmcraft that will work on xenial. Am I missing something?

mthaddon commented 3 years ago

https://github.com/canonical/operator/issues/517 seems possibly relevant here

sergiusens commented 3 years ago

Without looking too much into the error, it also looks like you would need to build-on 16.04 and not 20.04 to ensure your dependencies work on the minimum python version you wish to support (or use multiple build-on/run-on statements)

facundobatista commented 3 years ago

Hello! Tom, you're right, that issue is relevant here. You're getting the same problem related there, an incompatibility of the code with old Python. But it looks it's fixed in last April, so which version of the Operator Framework are you using?

mthaddon commented 3 years ago

@facundobatista the requirements.txt file has ops>=1.0,<2.0. It looks like that'll be using the latest release, which is 1.2.0 released in on April 21st. I'll confirm if I still see the same issue with the latest revision of the operator framework code.

mthaddon commented 3 years ago

I can confirm with git+https://github.com/canonical/operator/#egg=ops in requirements.txt and git as a build-package in the "parts/charm" section of charmcraft.yaml I can build a version of the ubuntu charm that deploys on xenial. Sorry for the noise.