Skip to content

Instantly share code, notes, and snippets.

@gnuoy
Last active May 1, 2023 05:53
Show Gist options
  • Save gnuoy/7d1fb815ac62323fd26db9d7c2d15f00 to your computer and use it in GitHub Desktop.
Save gnuoy/7d1fb815ac62323fd26db9d7c2d15f00 to your computer and use it in GitHub Desktop.

Do and don'ts

  • Any event that relates to the setup of the unit or application invoke the configure_charm method
  • Unit setup should be in configure_unit
  • Application setup should be in configure_application
  • Do not defer events (unless you really have to)
  • When writing a relation handle keep in mind the the handler may be used by other charms to avoid calling back to specific charm methods in the body of the handler. Instead have the charm pass eveything when the handler is initialaised. This is not always possible.

Dev tips

  • SSHing into a container

A unit consists of a pod made up of a charm container and one or more payload containers. The charm container can be accessed the normal way with:

juju ssh keystone/0

The payload container(s) can all be accessed by adding the --container flag. e.g.

juju ssh -m openstack --container neutron-server neutron/0

If you don't know the payload container names the just add garbage for the name and juju will list them:

juju ssh -m openstack --container garbage neutron/0 ERROR container "garbage" must be one of charm, neutron-server

  • If a unit is stuck coming up then you can use the kubectl command line to get more information:

The pod name is the unit name with the / replaced with a - so the pod for keystone/0 is keystone-0. The pods are in a namespace which corresponds to the model name. eg

kubectl describe pod -n openstack keystone-0

  • Install into the container

The charm and payload container do not have an editor in them by default but you can use apt to install one (or anything else).

  • Get adminrc details

The keystone charm has an action to retrieve admin credentials

juju run -m openstack keystone/0 get-admin-account

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment