canonical / charmcraft

Collaborate, build and publish charmed operators for Kubernetes, Linux and Windows.
Apache License 2.0
65 stars 70 forks source link

It looks like PR#1126 may have broken reactive builds; metadata.yaml is overwritten? #1150

Closed ajkavanagh closed 1 year ago

ajkavanagh commented 1 year ago

Bug Description

It looks like PR#1126 may have broken charm-build (the reactive builders) metadata.yaml creation, as it seems to immediately overwrite it. This is with --channel=latest/edge (2.3.0.post16+gited81be8). At least I think that is what may be going on. I was testing latest/edge for the ability to build on lunar (23.04).

The offending line appears to be at https://github.com/canonical/charmcraft/blob/ed81be89193deede1c4266c4c369ed7ce7d6b0be/charmcraft/commands/build.py#L181

The issue is that the built charms' metadata should look like this:

"name": "mysql-innodb-cluster"
"summary": "MySQL InnoDB Cluster"
"maintainer": "OpenStack Charmers <openstack-charmers@lists.ubuntu.com>"
"description": |
  MySQL InnoDB Cluster Charm deploys and manages the lifecycle of a
  MySQL InnoDB Cluster.
"tags":
- "openstack"
- "databases"
"series":
- "focal"
- "jammy"
- "lunar"
"requires":
  "certificates":
    "interface": "tls-certificates"
"provides":
  "shared-db":
    "interface": "mysql-shared"
  "db-router":
    "interface": "mysql-router"
  "db-monitor":
    "interface": "mysql-monitor"
    "scope": "container"
  "prometheus":
    "interface": "http"
"peers":
  "coordinator":
    "interface": "coordinator"
  "cluster":
    "interface": "mysql-innodb-cluster"
"resources":
  "mysql-shell":
    "type": "file"
    "filename": "mysql-shell.snap"
    "description": |
      Snap for mysql-shell
  "mysqld-exporter":
    "type": "file"
    "filename": "mysqld-exporter.snap"
    "description": |
      snap for mysqld prometheus exporter
"subordinate": !!bool "false"

but actually looks like this:

name: mysql-innodb-cluster
summary: MySQL InnoDB Cluster
maintainer: OpenStack Charmers <openstack-charmers@lists.ubuntu.com>
description: |
  MySQL InnoDB Cluster Charm deploys and manages the lifecycle of a
  MySQL InnoDB Cluster.
tags:
- databases
subordinate: false
series:
- focal
- jammy
- lunar
provides:
  shared-db:
    interface: mysql-shared
  db-router:
    interface: mysql-router
  db-monitor:
    interface: mysql-monitor
    scope: container
  prometheus:
    interface: http
...

To Reproduce

# fetch any reactive charm source, with a charmcraft.yaml
charmcraft pack
unzip -p <charm> metadata.yaml

Environment

charmcraft.yaml

type: charm

parts:
  charm:
    plugin: reactive
    reactive-charm-build-arguments:
      - --binary-wheels-from-source
      - --verbose
    build-packages:
      - tox
      - git
      - python3-dev
      - libffi-dev
      - libmysqlclient-dev
      - pkg-config
    source: src/
    build-snaps:
      - charm/latest/edge
    build-environment:
      - CHARM_INTERFACES_DIR: $CRAFT_PROJECT_DIR/interfaces/
      - CHARM_LAYERS_DIR: $CRAFT_PROJECT_DIR/layers/

bases:
  - build-on:
      - name: ubuntu
        channel: "20.04"
        architectures: [amd64]
    run-on:
      - name: ubuntu
        channel: "20.04"
        architectures: [amd64]
  - build-on:
      - name: ubuntu
        channel: "20.04"
        architectures: [s390x]
    run-on:
      - name: ubuntu
        channel: "20.04"
        architectures: [s390x]
  - build-on:
      - name: ubuntu
        channel: "20.04"
        architectures: [ppc64el]
    run-on:
      - name: ubuntu
        channel: "20.04"
        architectures: [ppc64el]
  - build-on:
      - name: ubuntu
        channel: "20.04"
        architectures: [arm64]
    run-on:
      - name: ubuntu
        channel: "20.04"
        architectures: [arm64]
  - build-on:
      - name: ubuntu
        channel: "22.04"
        architectures: [amd64]
    run-on:
      - name: ubuntu
        channel: "22.04"
        architectures: [amd64]
  - build-on:
      - name: ubuntu
        channel: "22.04"
        architectures: [s390x]
    run-on:
      - name: ubuntu
        channel: "22.04"
        architectures: [s390x]
  - build-on:
      - name: ubuntu
        channel: "22.04"
        architectures: [ppc64el]
    run-on:
      - name: ubuntu
        channel: "22.04"
        architectures: [ppc64el]
  - build-on:
      - name: ubuntu
        channel: "22.04"
        architectures: [arm64]
    run-on:
      - name: ubuntu
        channel: "22.04"
        architectures: [arm64]
  - build-on:
      - name: ubuntu
        channel: "23.04"
        architectures: [amd64]
    run-on:
      - name: ubuntu
        channel: "23.04"
        architectures: [amd64]
  - build-on:
      - name: ubuntu
        channel: "23.04"
        architectures: [s390x]
    run-on:
      - name: ubuntu
        channel: "23.04"
        architectures: [s390x]
  - build-on:
      - name: ubuntu
        channel: "23.04"
        architectures: [ppc64el]
    run-on:
      - name: ubuntu
        channel: "23.04"
        architectures: [ppc64el]
  - build-on:
      - name: ubuntu
        channel: "23.04"
        architectures: [arm64]
    run-on:
      - name: ubuntu
        channel: "23.04"
        architectures: [arm64]

Relevant log output

Log file too long, sadly.
syu-w commented 1 year ago

Hi, do you able to give me the repo of that reactive charm?

ajkavanagh commented 1 year ago

Hi, do you able to give me the repo of that reactive charm?

Sure, yes. it's https://opendev.org/openstack/charm-mysql-innodb-cluster

However, I'm converting it to a binary reactive charm (with lunar support), which is where I hit the issue: https://review.opendev.org/c/openstack/charm-mysql-innodb-cluster/+/886634

However, it should be reproducible with any charmcraft charm that uses the reactive plugin (note the review 886634 uses the reactive plugin, the master branch doesn't (yet)). Thanks.

ajkavanagh commented 1 year ago

Thanks very much for the fix @syu-w !

syu-w commented 1 year ago

@ajkavanagh do you able to confirm it is working now?

ajkavanagh commented 1 year ago

@syu-w I can confirm that I've built the mysql-innodb-cluster charm with 2.3.0.post17+git35adadf and the metadata.yam, config.yaml and actions.yaml are all as per the generated output of charm build. Also the lunar (23.04) base also works. Thanks!