I’m working on a new beginner level tutorial series covering “hooks”.
Draft material is here:
https://github.com/erik78se/Tutorial-Build-a-quick-charm
When writing this tutorial I’ve made some assumptions:
- charm-tools is the way to enter charming
- Using “bash” to learn about hooks is the best start for a beginner with none or little python experience (trying to win-over traditional sysadmins to juju).
- Not mixing in anything about reactive concepts at all at this place since its the “hooks” that I want to have all focus on.
I’ll soon post in the Users category about this, but there are a number of things that makes the tutorials be very “buggy” which I think can be done better.
So, let me describe some context for the issues:
- I’m using charm 2.5.2 to create a charm from template:
charm create -t bash my-tweaks
The generated charm is populated with the following files & hooks:
├── config.yaml
├── hooks
│ ├── config-changed
│ ├── install
│ ├── relation-name-relation-broken
│ ├── relation-name-relation-changed
│ ├── relation-name-relation-departed
│ ├── relation-name-relation-joined
│ ├── start
│ ├── stop
│ └── upgrade-charm
├── icon.svg
├── metadata.yaml
├── README.ex
└── revision
Here we go:
Problem 1: I have to create an empty hook file called: “hook.template” for the charm to build which makes no sense what-so-ever. Its non trivial to figure out this workaround to create a trivial bash charm. https://github.com/juju/charm-tools/issues/98
Suggested fix: Make sure that no python or reactive pieces are needed to create “bash” charms. Anyone not familiar with advanced charming with reactive and python will give up at this stage.
Problem 2: A few hooks are not added to the hooks directory that causes error at various places in the event cycle and state transitions for juju.
The missing hooks I have found missing so far while performing “juju deploy”, “juju upgrade-charm” etc. are:
- Missing “leader-elected” : fails “juju deploy”
- Missing “leader-settings-changed” : fails “juju upgrade-charm”
- Missing “update-status” : juju fails when charm is actually deployed
E.g. Using standard procedures for installing and upgrading a bash charm will fail and its non trivial to figure out why and how. This will make a beginner level charmer give up on juju. https://github.com/juju/charm-tools/issues/503
Suggested fix: Don’t allow a juju deploy to “fail”/“error” with charms not implementing each and every hook unless strictly needed to complete run of the state machine. Instead allow a deploy to move on alerting that there are missing hooks present. Be nice also to programmers that are not 1337.
Problem 3: The “install” hook is populated with code which always will fail. It contains “apt-get install charmname” which causes the charm to break per default. https://github.com/juju/charm-tools/issues/504
Suggested fix: Add content to the install script that actually make sense, such as "status-set active “Ready” or/and an url reference to the available hook-tools. https://docs.jujucharms.com/2.5/en/reference-hook-tools
Problem 4: When running “charm proof”, it complains about “layer.yaml” missing. Is this really needed for bash-charms? https://github.com/juju/charm-tools/issues/506
Suggested fix: Not sure why this is a warning for a bash charm.
Problem 5: This closed bug still prevails and causes confusion https://github.com/juju/charm-tools/issues/502
Problem 6: Its not good that the produced charms from “charm create” always produces non-usable metadata.yaml as I try to describe here: https://github.com/juju/charm-tools/issues/505