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

docs: add howto guides for switching from the charm plugin #1967

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lengau
Copy link
Collaborator

@lengau lengau commented Oct 17, 2024

This adds howto guides to switch from the charm plugin to the python and poetry plugins.

@lengau lengau requested review from medubelko and a team October 17, 2024 20:25
@lengau lengau linked an issue Oct 17, 2024 that may be closed by this pull request
This adds howto guides to switch from the charm plugin to the python
and poetry plugins.
Copy link
Contributor

@mattculler mattculler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clear!

@jnsgruk
Copy link
Member

jnsgruk commented Oct 18, 2024

Gave this a go here: jnsgruk/zinc-k8s-operator#288

Might be worth including a section about using override-pull as a place where people can generate requirements'txt if they need to.

I guess they could also use override-build and just place their generation code before craftctl default.

Edit: lots of failed integration tests when I changed to this; will investigate.

@jnsgruk
Copy link
Member

jnsgruk commented Oct 18, 2024

Heh. The python plugin doesn't seem to have included any dispatch file...

ubuntu@ubuntu-noble-2e39:~/zinc_charm_unzipped$ ls -la
total 39480
drwxrwxr-x 5 ubuntu ubuntu     4096 Oct 18 10:30 .
drwxr-xr-x 9 ubuntu ubuntu     4096 Oct 18 10:30 ..
drwxrwxr-x 2 ubuntu ubuntu     4096 Oct 18 10:30 bin
drwxrwxr-x 3 ubuntu ubuntu     4096 Oct 18 10:30 lib
drwxrwxr-x 3 ubuntu ubuntu     4096 Oct 18 10:30 lib64
-rw-r--r-- 1 ubuntu ubuntu      255 Oct 18 10:21 manifest.yaml
-rw-r--r-- 1 ubuntu ubuntu     1402 Oct 18 10:21 metadata.yaml
-rw-r--r-- 1 ubuntu ubuntu      169 Oct 18 10:21 pyvenv.cfg

Edit: switched to the latest/edge channel and things seem better:

ubuntu@ubuntu-noble-2e39:~/data/code/charms/zinc-k8s-operator$ unzip -l ./zinc-k8s_amd64.charm | grep -v python3
Archive:  ./zinc-k8s_amd64.charm
  Length      Date    Time    Name
---------  ---------- -----   ----
      272  2024-10-18 10:38   manifest.yaml
     1402  2024-10-18 10:38   metadata.yaml
      673  2024-10-18 10:38   dispatch
      188  2024-10-18 10:34   venv/pyvenv.cfg
     2680  2024-10-03 08:44   src/zinc.py
     3922  2024-10-03 08:44   src/charm.py
        0  2022-05-31 14:57   src/prometheus_alert_rules/.gitkeep
      294  2022-07-30 20:33   src/prometheus_alert_rules/zinc_missing.rule
        0  2022-05-31 14:57   src/loki_alert_rules/.gitkeep
    20957  2023-08-23 13:19   src/grafana_dashboards/zinc.json.tmpl
    99854  2024-08-19 14:12   lib/charms/loki_k8s/v0/loki_push_api.py
    30560  2024-08-28 16:53   lib/charms/traefik_k8s/v2/ingress.py
    96662  2024-08-19 14:12   lib/charms/prometheus_k8s/v0/prometheus_scrape.py
    34280  2024-10-02 08:52   lib/charms/parca/v0/parca_scrape.py
    80536  2024-08-19 14:12   lib/charms/grafana_k8s/v0/grafana_dashboard.py
     9975  2024-10-02 08:52   lib/charms/observability_libs/v0/juju_topology.py
---------                     -------
 41499875                     2412 files

Alas, no dice on deploying, though...

ubuntu@ubuntu-noble-2e39:~/zinc_charm/venv$ juju debug-log
unit-zinc-k8s-0: 10:39:59 WARNING unit.zinc-k8s/0.install ln: failed to create symbolic link '/var/lib/juju/agents/unit-zinc-k8s-0/charm/venv/bin/python': No such file or directory
unit-zinc-k8s-0: 10:39:59 WARNING unit.zinc-k8s/0.install /var/lib/juju/agents/unit-zinc-k8s-0/charm/dispatch: 16: exec: /var/lib/juju/agents/unit-zinc-k8s-0/charm/venv/bin/python: not found
unit-zinc-k8s-0: 10:39:59 ERROR juju.worker.uniter.operation hook "install" (via hook dispatching script: dispatch) failed: exit status 127

@lengau
Copy link
Collaborator Author

lengau commented Oct 18, 2024

Thanks @jnsgruk! Looks like I forgot to test with python-keep-bins: false (the default). I've made a fix PR, but as a temporary workaround you should also be able to set python-keep-bins: true in the part definition.

@lengau
Copy link
Collaborator Author

lengau commented Oct 18, 2024

@jnsgruk re: the override-pull - while people could do that, I'd prefer not to document it here as I'd like to encourage people to check in some sort of lock file. For the uv case, @bepri is heading up our addition of uv plugins for 25.04

Copy link
Contributor

@medubelko medubelko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting these together!

docs/howto/charm-to-python.rst Outdated Show resolved Hide resolved
@@ -0,0 +1,107 @@
.. _howto-migrate-to-poetry:

Migrate from the ``charm`` plugin to Poetry
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with existing docs and docs best practices, we should use the form Charm plugin and Python plugin.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed!

docs/howto/charm-to-poetry.rst Show resolved Hide resolved
docs/howto/charm-to-poetry.rst Outdated Show resolved Hide resolved
docs/howto/charm-to-poetry.rst Outdated Show resolved Hide resolved
docs/howto/charm-to-poetry.rst Outdated Show resolved Hide resolved
docs/howto/charm-to-poetry.rst Outdated Show resolved Hide resolved
Migrate from the ``charm`` plugin to the ``python`` plugin
==========================================================

The ``python`` Charmcraft plugin offers a faster, stricter means of packing an operator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Charmcraft plugin

Do we need to be this specific here? "Python Charmcraft plugin" tripped me up as a phrase.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because it works slightly differently from the Rockcraft plugin, the Snapcraft plugin, etc.

docs/howto/charm-to-python.rst Outdated Show resolved Hide resolved
docs/howto/charm-to-python.rst Show resolved Hide resolved
lengau and others added 2 commits November 1, 2024 10:50
Co-authored-by: Michael DuBelko <michael.dubelko@gmail.com>
@lengau lengau requested a review from medubelko November 1, 2024 10:12
Select compatible versions of ``pip`` and ``poetry``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The ``poetry`` plugin requires at least pip 22.3, released in October 2022. If the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The ``poetry`` plugin requires at least pip 22.3, released in October 2022. If the
The Poetry plugin requires at least `pip 22.3
<https://pypi.org/project/pip/22.3>`_, released in October 2022. If the

Include extra files
-------------------

A ``poetry`` plugin only includes the contents of the ``src`` and ``lib`` directories
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A ``poetry`` plugin only includes the contents of the ``src`` and ``lib`` directories
A Poetry plugin only includes the contents of the ``src`` and ``lib`` directories

Migrate from the Charm plugin to the Python plugin
==================================================

The Python Charmcraft plugin offers a faster, stricter means of packing an operator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Python Charmcraft plugin offers a faster, stricter means of packing an operator
The Python plugin in Charmcraft offers a faster, stricter means of packing an operator

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

Successfully merging this pull request may close these issues.

Document the python and poetry plugins
4 participants