Merge ~ubuntu-docker-images/ubuntu-docker-images/+git/prometheus-alertmanager:use-snap-architecture-21.04 into ~ubuntu-docker-images/ubuntu-docker-images/+git/prometheus-alertmanager:0.21-21.04

Proposed by Sergio Durigan Junior
Status: Merged
Merged at revision: df6728bf51fa7d40ab45adf463cdc932dab9ff26
Proposed branch: ~ubuntu-docker-images/ubuntu-docker-images/+git/prometheus-alertmanager:use-snap-architecture-21.04
Merge into: ~ubuntu-docker-images/ubuntu-docker-images/+git/prometheus-alertmanager:0.21-21.04
Diff against target: 12 lines (+1/-1)
1 file modified
Dockerfile (+1/-1)
Reviewer Review Type Date Requested Status
Athos Ribeiro Approve
Bryce Harrington Pending
Canonical Server Pending
Review via email: mp+403986@code.launchpad.net

Description of the change

This MP fixes a problem that is affecting snap-based images.

Because we don't explicitly specify an architecture when querying snapcraft for the snap download URL, we end up always getting the amd64 snap, even on non-amd64 architectures. This means that that we install amd64 binaries in the non-amd64 OCI images, which end up making them unusable.

The fix here is to specify the architecture by setting the X-Ubuntu-Architecture header. I'm getting the value from "dpkg --print-architecture", which will always be available and will print the correct architecture name (snapcraft uses Debian-like names).

I tested this on a ppc64el machine and it works.

To post a comment you must log in.
Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote (last edit ):

Hi Sergio,

Thanks for the MP!

Looks good to me.

I tested it by running the changed curl command locally in an x86_64 machine and verifying the snap file, which is as expected. Then, I substituted the introduced dpkg command for different architectures to make sure the contents of the snap contain binaries for the requested architectures.

For instance (s90x):

$ file bin/alertmanager
prom/bin/alertmanager: ELF 64-bit MSB executable, IBM S/390, version 1 (SYSV), statically linked, Go BuildID=Li3q76PL8Nz7l2TuPIhI/LCp2e7c9ccaiwizuBy2k/8SgumMYUWSkk59-xU5IX/fuPcO5vH5LUSM51o3oq6, not stripped

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Dockerfile b/Dockerfile
2index 28a5cba..97c3bc9 100644
3--- a/Dockerfile
4+++ b/Dockerfile
5@@ -7,7 +7,7 @@ RUN set -eux; \
6 jq curl ca-certificates squashfs-tools; \
7 # taken from https://snapcraft.io/docs/build-on-docker
8 # Alternatively, we can install snapd, and issue `snap download prometheus-alertmanager`
9- curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/prometheus-alertmanager?channel=21.04/edge' | jq '.download_url' -r) --output prometheus-alertmanager.snap; \
10+ curl -L $(curl -H 'X-Ubuntu-Series: 16' -H "X-Ubuntu-Architecture: $(dpkg --print-architecture)" 'https://api.snapcraft.io/api/v1/snaps/details/prometheus-alertmanager?channel=21.04/edge' | jq '.download_url' -r) --output prometheus-alertmanager.snap; \
11 mkdir -p /snap; \
12 unsquashfs -d /snap/prometheus-alertmanager prometheus-alertmanager.snap
13

Subscribers

People subscribed via source and target branches

to all changes: