Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
carlcsaposs-canonical opened this issue May 16, 2024 · 4 comments
Closed
Assignees
Labels
Bug Something isn't working

Comments

@carlcsaposs-canonical
Copy link
Contributor

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)
@carlcsaposs-canonical carlcsaposs-canonical added the Bug Something isn't working label May 16, 2024
Copy link

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 carlcsaposs-canonical changed the title Multi-arch image incorrectly uploaded to Charmhub registry Multi-arch OCI image incorrectly uploaded to Charmhub registry May 16, 2024
lengau added a commit that referenced this issue Jun 12, 2024
carlcsaposs-canonical added a commit to canonical/data-platform-workflows that referenced this issue Jun 19, 2024
charmcraft 2.7.0 contains a fix for multi-arch OCI images
issue: canonical/charmcraft#1685
fix: canonical/charmcraft#1708

However, it fixes it in a "backwards-compatible" way—if the image is available locally, it will still upload it incorrectly.

Stop downloading the image locally & always use GHCR so that charmcraft uploads the image correctly

This will break on charmcraft < 2.7.0
@carlcsaposs-canonical
Copy link
Contributor Author

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
Copy link
Contributor Author

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

carlcsaposs-canonical added a commit to canonical/data-platform-workflows that referenced this issue Jun 19, 2024
…#198)

charmcraft 2.7.0 contains a fix for multi-arch OCI images issue:
canonical/charmcraft#1685 fix:
canonical/charmcraft#1708

However, it fixes it in a "backwards-compatible" way—if the image is
available locally, it will still upload it incorrectly.

Stop downloading the image locally & always use GHCR so that charmcraft
uploads the image correctly

This will break on charmcraft < 2.7.0
@lengau
Copy link
Collaborator

lengau commented Jul 16, 2024

What's currently in Charmcraft 3 is all that's currently planned, though I can see an argument for charmcraft 4 requiring the user to explicitly include docker-daemon: in the image path to get it from local Docker daemon.

@lengau lengau closed this as completed Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants