bundle with local metadata v2 k8s sidecar charm fails for "metadata v1"

Bug #1936281 reported by Leon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
High
Simon Richardson

Bug Description

I am following [this doc](https://juju.is/docs/sdk/bundle-reference) for creating a local bundle. When I try do deploy a minimal bundle, juju incorrectly claims that the metadata is v1:

$ git clone --depth 1 https://github.com/canonical/alertmanager-operator.git

$ cat bundle.yaml
bundle: kubernetes
applications:
  alertmanager-k8s:
    charm: "/tmp/test/alertmanager-operator"
    scale: 1
    resources:
      alertmanager-image: "ubuntu/prometheus-alertmanager"

$ juju deploy ./bundle.yaml
ERROR cannot deploy bundle: containers with metadata v1 not valid

yet the [metadata.yaml](https://github.com/canonical/alertmanager-operator/blob/main/metadata.yaml) is v2.

Changed in juju:
assignee: nobody → Simon Richardson (simonrichardson)
milestone: none → 2.9.10
importance: Undecided → High
John A Meinel (jameinel)
Changed in juju:
status: New → In Progress
Revision history for this message
Simon Richardson (simonrichardson) wrote :

So the real problem here is that you're missing a manifest.yaml. To truly be a metadata v2, you also have to have a manifest.yaml. The manifest.yaml can either be created manually (see below) or via `charmcraft build`.

Example of a manifest.yaml:

    bases:
    - name: ubuntu
      architectures:
      - amd64
      channel: '20.04'

----

Although this is user error, the error message can be vastly improved to at least explain why juju thinks it's a v1 metadata.

This bug will be closed once the error message is improved.

Revision history for this message
Leon (sed-i) wrote :

After adding the manifest.yaml I am getting the following (surprising) messages:

Executing changes:
- upload charm alertmanager-operator from charm-hub for series focal with architecture=amd64
ERROR cannot deploy bundle: invalid charm "alertmanager-operator": has no hooks nor dispatch file

Revision history for this message
Simon Richardson (simonrichardson) wrote :

Can we try `charmcraft build` instead?

Revision history for this message
Leon (sed-i) wrote :

Same thing.
Here's a full reproduction:

$ git clone https://github.com/sed-i/lma-light-bundle.git

$ git clone https://github.com/canonical/alertmanager-operator.git

$ cd alertmanager-operator

$ charmcraft build
Created 'alertmanager-k8s.charm'.

$ unzip -l alertmanager-k8s.charm | grep manifest
      147 2021-07-15 13:35 manifest.yaml

$ cd ../lma-light-bundle

$ cat bundle-local.yaml
---
applications:
  alertmanager:
    charm: "../alertmanager-operator"
    scale: 1
    resources:
      alertmanager-image: "ubuntu/prometheus-alertmanager"
bundle: kubernetes
series: ~

$ juju deploy ./bundle-local.yaml
ERROR cannot deploy bundle: containers with metadata v1 not valid

Revision history for this message
Leon (sed-i) wrote :

If I extract manifest.yaml from the *.charm into the repo root, then I get:

$ juju deploy ./bundle-local.yaml
Executing changes:
- upload charm /home/tux/Downloads/test/allinone/alertmanager-operator for series focal with architecture=amd64
ERROR cannot deploy bundle: invalid charm "alertmanager-operator": has no hooks nor dispatch file

Revision history for this message
Simon Richardson (simonrichardson) wrote :

So I got this to work without a problem. I think this is the fact you're trying to deploy the source of the charm, _not_ the build artifact.

    git clone --depth 1 https://github.com/canonical/alertmanager-operator.git
    cd alertmanager-operator
    charmcraft build
    cd -

    cat bundle.yaml
    bundle: kubernetes
    applications:
    alertmanager-k8s:
        charm: ./alertmanager-operator/alertmanager-k8s.charm
        scale: 1
        resources:
        alertmanager-image: "ubuntu/prometheus-alertmanager"

    juju bootstrap microk8s mk8s
    juju deploy ./bundle.yaml

Hope this helps.

Revision history for this message
Leon (sed-i) wrote :

That works, thanks!

I had "local:" as I was following https://bugs.launchpad.net/juju/+bug/1936276

The prefix to the charm name ('local:'), as exported via juju export-bundle, was the problem.
Maybe "./" would have been a better hint :)

Revision history for this message
Simon Richardson (simonrichardson) wrote :
Changed in juju:
status: In Progress → Fix Committed
Changed in juju:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.