Juju charms and LXD profiles - gotchas and troubleshooting and potential recovery

If using charms with lxd profiles, it is highly recommended to be using juju 2.7.8 or later.

Introduction

This post will cover known gotchas and how to troubleshoot and recover when using lxd profiles applied by juju via a charm. This feature is covered in the Charms and LXD Profiles section of Using LXD with Juju - advanced .

The original spec can be found here LXD profile updates permitted by charms specification

For charm authors

Valid LXD profiles are not a one size fits all.

Over the course of this feature, we’ve found that many things you can put into a profile, do not work on all machines. Primarily this is true to device definitions. However this applies to some configuration such as kernel modules, e.g. nbd cannot be loaded into every kernel.

It is recommended that charm authors try their profiles on multiple machines before adding to a charm. Let charm user’s know of potential issues.

For users

Handy to know

Juju names lxd profile from charms based on the model the charm is in, the application name and charm revision. E.G. cs:neturon-openvswitch~276 in the default model would have a profile called juju-default-neutron-openvswitch-276.

Every upgrade of the charm changes the name of the profile to reflect the current version. Profiles are removed and added based on the new name and contents. Prior profiles are not edited.

Charm profiles are applied to every machine if the cloud bootstrapped is localhost or lxd, as well as any machine deployed with the placement directive --to lxd

Profile names can be seen in the yaml output of juju status.
$ juju status  neutron-openvswitch  --format yaml
model:
  name: seven
...
applications:
  neutron-openvswitch:
    charm: cs:neutron-openvswitch-276
...
    charm-profile: juju-seven-neutron-openvswitch-276
...
Profile contents can be seen on the machine info from juju status.

Note: this is what juju believes the profile should be, not what found from lxd profile show juju-seven-neutron-openvswitch-276.

$ juju status  neutron-openvswitch  --format yaml
model:
  name: seven
...
machines:
  "0":
...
    lxd-profiles:
      juju-seven-neutron-openvswitch-276:
        config:
          linux.kernel_modules: openvswitch,ip_tables,ip6_tables
        description: ""
        devices: {}
...

Is the charm profile written to lxd correctly?

To verify if the profile is written correctly to lxd, use the juju status or juju machines command (–format yaml) to find what the profile should be, then look at the profile via the lxc profile show command.

Example
$ juju machines  --format yaml
model:
  name: seven
machines:
  "0":
...
    instance-id: juju-5f1684-0
...
    lxd-profiles:
      juju-seven-neutron-openvswitch-276:
        config:
          linux.kernel_modules: openvswitch,ip_tables,ip6_tables
        description: ""
        devices: {}
...

$ lxc profile show !$
lxc profile show juju-seven-neutron-openvswitch-276
config:
  linux.kernel_modules: openvswitch,ip_tables,ip6_tables
description: ""
devices: {}
name: juju-seven-neutron-openvswitch-276
used_by:
- /1.0/instances/juju-5f1684-0

Note: if the profile is written to an LXD container, you just first juju ssh to the machine the container is located on.

Editing an existing lxd profile applied by juju

If you are considering this, please check for related lxd profile bugs, or file a new bug with juju if none of the known bugs fit.

Find the profile’s name and edit it. You may need to edit a profile with the same name on multiple lxd machines, depending on your deployment.

Example
$ juju status  neutron-openvswitch  --format yaml | grep charm-profile
    charm-profile: juju-seven-neutron-openvswitch-276

$ lxd profile edit  juju-seven-neutron-openvswitch-276

Note: if the profile is written to an LXD container e.g 0/lxd/4, you must first juju ssh to the machine the container is located on.

Note: this change will be applied to any lxc machine listed under used_by: and may trigger a reboot of the machine.

1 Like