Open ca-scribner opened 7 months ago
Thank you for reporting us your feedback!
The internal ticket has been created: https://warthogs.atlassian.net/browse/KF-5580.
This message was autogenerated
My quick experience on this, I had played around with possible solution 3 (point 1 described in that spec section). AFAIR, this was working properly (example function) and the function was acting like it lived inside the charm's code.
Also, I had tried adding the libs to chisme
and having them delivered with the code (by default) but I couldn't get the charm to locate those (not saying it's impossible). Example implementation here and here.
What I tried to do is fetch-lib in root directory, like this:
$ charmcraft fetch-lib charms.prometheus_k8s.v0.prometheus_scrape
Library charms.prometheus_k8s.v0.prometheus_scrape version 0.47 downloaded.
$ ll lib/charms
total 4.0K
drwxrwxr-x 3 rgildein rgildein 4.0K May 22 16:10 prometheus_k8s
then I changed the setup.cfg
to include package_data, like this:
[options]
...
include_package_data = True
[options.package_data]
* = charms/*.py
With these changes, we can use libs directly in chisme, like this:
from lib.charms.prometheus_k8s.v0.prometheus_scrape import MetricsEndpointProvider
With this approach it should be possible to have different version of lib in charm and different version in chisme, so if chisme using lib smartly and charm will never import from lib.charms
, it will be possible to do easy bump version of any lib in chisme. e.g. charm can keep using same function from chisme (foo(self, port)
) and all logic to use new version of lib will be done on chisme side (foo
change inside).
Context
We've had times where we'd like to move a function that depends on a charm library to chisme (for example, in canonical/envoy-operator#87 and canonical/kfp-operators#436, which both have the same
K8sServiceInfoComponent
). Because these depend on a charm library, chisme would then need that charm library.An option could do a simple vendoring of the charm libraries in chisme, but then chisme would:
charmcraft fetch-lib
within the charm to update libraries)This likely is not manageable, at least not without some advanced stuff.
Some possible solutions:
pip install chisme[k8s-service-lib]
). I think then in the chisme repo we'd still install the charm lib (somehow manually?) and use it for testing (maybe installing several versions in a matrix of tests) but the charm lib wouldn't ship thoseTo me, (1) is probably the easiest
What needs to get done
Definition of Done