Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Cannot use tactics with layer-caas-base #24

Closed
jamesbeedy opened this issue Oct 3, 2019 · 2 comments
Closed

Cannot use tactics with layer-caas-base #24

jamesbeedy opened this issue Oct 3, 2019 · 2 comments

Comments

@jamesbeedy
Copy link

jamesbeedy commented Oct 3, 2019

Trying to create a tactic for my k8s charm and experiencing an issue. The issue is that I cannot build my charm without including the wheelhouse tactic (from layer-caas-base) in my charm.

Building my charm shows (layer.yaml)

bdx@devdev:~/allcode/charms/layers/layer-elastic-operator$ make build
rm -rf .tox/
rm -rf build/
rm -rf charm-store-push-result.txt
tox -e build
build create: /home/bdx/allcode/charms/layers/layer-elastic-operator/.tox/build
build installdeps: -r/home/bdx/allcode/charms/layers/layer-elastic-operator/test-requirements.txt
build installed: atomicwrites==1.3.0,attrs==19.2.0,entrypoints==0.3,filelock==3.0.12,flake8==3.7.8,importlib-metadata==0.23,mccabe==0.6.1,more-itertools==7.2.0,packaging==19.2,pep8==1.7.1,pkg-resources==0.0.0,pluggy==0.13.0,py==1.8.0,pycodestyle==2.5.0,pyflakes==2.1.1,pyparsing==2.4.2,pytest==5.2.0,six==1.12.0,toml==0.10.0,tox==3.14.0,virtualenv==16.7.5,wcwidth==0.1.7,yapf==0.28.0,zipp==0.6.0
build runtests: PYTHONHASHSEED='0'
build runtests: commands[0] | sh -c snap list charm 2>/dev/null || sudo snap install charm --classic
Name   Version  Rev  Tracking  Publisher  Notes
charm  2.7.1    390  stable    johnsca    classic
build runtests: commands[1] | charm build --log-level DEBUG -o /home/bdx/allcode/charms/layers/layer-elastic-operator/build src
build: {
  "CHARM_BUILD_DIR": null,
  "CHARM_INTERFACES_DIR": "/home/bdx/allcode/charms/layers/layer-elastic-operator/interfaces",
  "CHARM_LAYERS_DIR": "/home/bdx/allcode/charms/layers/layer-elastic-operator/layers",
  "INTERFACE_PATH": null,
  "JUJU_REPOSITORY": "/home/bdx/allcode/charms/layers/layer-elastic-operator/build",
  "LAYER_PATH": null,
  "_charm": "src",
  "_charm_metadata": {
    "description": "Elastic.co K8S operator.\n",
    "display-name": "elastic-operator",
    "maintainers": [
      "Omnivector Solutions <[email protected]>"
    ],
    "name": "elastic-operator",
    "resources": {
      "elastic_operator_image": {
        "description": "Elastic operator image.",
        "type": "oci-image"
      }
    },
    "series": [
      "kubernetes"
    ],
    "storage": {
      "cert": {
        "location": "/tmp/cert",
        "type": "filesystem"
      }
    },
    "summary": "Elastic Operator",
    "tags": [
      "elastic",
      "elastic.co"
    ]
  },
  "_name": null,
  "_top_layer": null,
  "_warned_home": false,
  "build_dir": "/home/bdx/allcode/charms/layers/layer-elastic-operator/build/builds",
  "cache_dir": "/home/bdx/.cache/charm/27022",
  "config": "BuildConfig({'_tactics': [], 'configured': False})",
  "debug": false,
  "description": false,
  "force": false,
  "force_color": false,
  "hide_metrics": false,
  "interface_service": null,
  "layer_index": null,
  "log_level": "DEBUG",
  "no_local_layers": false,
  "output_dir": "/home/bdx/allcode/charms/layers/layer-elastic-operator/build",
  "report": false,
  "series": null,
  "verbose": false,
  "wheelhouse_overrides": null
}
charmtools.fetchers: git rev-parse HEAD: b'4ddd74e05e0eff93ffaa7a4763a91b2b09a860ea\n'
build: Destination charm directory: /home/bdx/allcode/charms/layers/layer-elastic-operator/build/builds/elastic-operator
charmtools.build.fetchers: Checking layer index: https://juju.github.io/layer-index/layers/caas-base.json
charmtools.build.fetchers: Found repo: https://github.com/juju-solutions/layer-caas-base.git
charmtools.fetchers: git clone https://github.com/juju-solutions/layer-caas-base.git /home/bdx/.cache/charm/27022/layer/tmps9oqkmm6: b"Cloning into '/home/bdx/.cache/charm/27022/layer/tmps9oqkmm6'...\nwarning: templates not found /snap/charm/390/share/git-core/templates\n"
charmtools.fetchers: git rev-parse HEAD: b'fac96d3e2cc3b67fd450985800377643e8e13c73\n'
charmtools.build.fetchers: Copying /home/bdx/.cache/charm/27022/layer/tmps9oqkmm6 to /home/bdx/.cache/charm/27022/layer/caas-base
charmtools.build.fetchers: Cleaning up /home/bdx/.cache/charm/27022/layer/tmps9oqkmm6
Traceback (most recent call last):
  File "/snap/charm/390/bin/charm-build", line 11, in <module>
    load_entry_point('charm-tools==2.7.1', 'console_scripts', 'charm-build')()
  File "/snap/charm/390/lib/python3.6/site-packages/charmtools/build/builder.py", line 941, in main
    build()
  File "/snap/charm/390/lib/python3.6/site-packages/charmtools/build/builder.py", line 649, in __call__
    self.generate()
  File "/snap/charm/390/lib/python3.6/site-packages/charmtools/build/builder.py", line 592, in generate
    layers = self.fetch()
  File "/snap/charm/390/lib/python3.6/site-packages/charmtools/build/builder.py", line 273, in fetch
    return self.fetch_deps(self.top_layer)
  File "/snap/charm/390/lib/python3.6/site-packages/charmtools/build/builder.py", line 278, in fetch_deps
    self.fetch_dep(layer, results)
  File "/snap/charm/390/lib/python3.6/site-packages/charmtools/build/builder.py", line 313, in fetch_dep
    base_layer.fetch()
  File "/snap/charm/390/lib/python3.6/site-packages/charmtools/build/builder.py", line 114, in fetch
    self._name = self.config.name
  File "/snap/charm/390/lib/python3.6/site-packages/charmtools/build/builder.py", line 51, in config
    self._config.configure(self.config_file)
  File "/snap/charm/390/lib/python3.6/site-packages/charmtools/build/config.py", line 66, in configure
    tactic = load_tactic(name, basedir)
  File "/snap/charm/390/lib/python3.6/site-packages/charmtools/build/tactics.py", line 1282, in load_tactic
    obj = utils.load_class(dpath, basedir)
  File "/snap/charm/390/lib/python3.6/site-packages/charmtools/utils.py", line 333, in load_class
    module = importlib.import_module(module_path)
  File "/snap/charm/390/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tactics.wheelhouse'
ERROR: InvocationError: '/snap/bin/charm build --log-level DEBUG -o /home/bdx/allcode/charms/layers/layer-elastic-operator/build src'
__________________________________________________________ summary __________________________________________________________
ERROR:   build: commands failed
Makefile:20: recipe for target 'build' failed
make: *** [build] Error 1

Adding the wheelhouse.py tactic to my tactics/ and to my layer.yaml allows the charm to build.

This issue only presents itself when using layer-caas-base in a k8s charm and does not happen when building a legacy charm with layer-basic.

Any ideas?

@johnsca
Copy link
Contributor

johnsca commented Oct 3, 2019

The caas-base layer includes a custom WheelhouseTactic to override the default one built into charm build to account for the fact that k8s charms cannot perform the normal bootstrap and installation, so instead of bundling packaged wheel or egg files, it has to essentially create an embedded virtualenv. However, both the tactics/ directory and the tactics: [] list in layer.yaml should be merged without you having to re-specify and include that custom tactic.

That the merging isn't happening as it should is a bug with charm build. Would you mind moving this issue over to charm-tools?

@jamesbeedy
Copy link
Author

Moved to juju/charm-tools#551

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants