canonical / charmcraft

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

Multi-arch OCI image incorrectly uploaded to Charmhub registry #1685

Open carlcsaposs-canonical opened 1 month ago

carlcsaposs-canonical commented 1 month ago

Bug Description

charmcraft upload-resource with a multi-arch image (e.g. https://github.com/canonical/charmed-postgresql-rock/pkgs/container/charmed-postgresql/208426154?tag=14.11-22.04_edge) uploads the amd64 image (if running charmcraft on amd64 machine) to the Charmhub registry

Context: https://warthogs.atlassian.net/browse/DPE-4280 https://matrix.to/#/!LhFxJIPEcCacgdMghH:ubuntu.com/$JMmA26BWFkqAKsCJ0tfAx4fpVOSndhej3-CYHwHyBpc?via=ubuntu.com&via=matrix.org

To Reproduce

  1. Release charm with multi-arch image using charmcraft on amd64 machine (using upload-resource with ghcr.io/canonical/charmed-postgresql:14.11-22.04_edge@sha256:31cf150b4523481202c1ff9b7b5d7f0b36729edad89d61242d8f1eb56b2912c0)
  2. juju deploy charm on arm64 machine
  3. Inspect juju debug-log
    ops.pebble.ChangeError: cannot perform the following tasks:
    - Start service "postgresql" (cannot start service: fork/exec /usr/bin/patroni: exec format error)

Note: if juju deploy ./postgresql-k8s.charm --resource postgresql-image=ghcr.io/canonical/charmed-postgresql:14.11-22.04_edge@sha256:31cf150b4523481202c1ff9b7b5d7f0b36729edad89d61242d8f1eb56b2912c0 is used on amd64 or arm64, the charm deploys correctly

Environment

Ubuntu 22.04 amd64

charmcraft.yaml

type: "charm"
bases:
  - name: ubuntu
    channel: "22.04"
    architectures: [amd64]
  - name: ubuntu
    channel: "22.04"
    architectures: [arm64]
parts:
  charm:
    override-pull: |
      craftctl default
      if [[ ! -f requirements.txt ]]
      then
          echo 'ERROR: Use "tox run -e build-dev" instead of calling "charmcraft pack" directly' >&2
          exit 1
      fi
    build-packages:
      - libffi-dev
      - libssl-dev
      - rustc
      - cargo
      - pkg-config
      - libpq-dev
    charm-strict-dependencies: true
  libpq:
    build-packages:
      - libpq-dev
    plugin: dump
    source: /usr/lib/
    source-type: local
    prime:
      - lib/
    organize:
      "*-linux-gnu/libpq.so*": lib/

Relevant log output

ops.pebble.ChangeError: cannot perform the following tasks:
- Start service "postgresql" (cannot start service: fork/exec /usr/bin/patroni: exec format error)
syncronize-issues-to-jira[bot] commented 1 month ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-2922.

This message was autogenerated

carlcsaposs-canonical commented 2 weeks ago

from testing https://github.com/canonical/postgresql-k8s-operator/actions/runs/9577566037/job/26407018728?pr=490 it appears that the issue is fixed on 2.7 if no local image is present

thank you @lengau!

carlcsaposs-canonical commented 2 weeks ago

is it planned to deprecate the local image upload & remove it in a future charmcraft major version (to avoid mistakes)?