Merge ~ubuntu-docker-images/ubuntu-docker-images/+git/grafana:use-snap-architecture-20.04 into ~ubuntu-docker-images/ubuntu-docker-images/+git/grafana:7.2-20.04

Proposed by Sergio Durigan Junior
Status: Merged
Merged at revision: 98398368d492e698b5811390b04fcbb706a005d3
Proposed branch: ~ubuntu-docker-images/ubuntu-docker-images/+git/grafana:use-snap-architecture-20.04
Merge into: ~ubuntu-docker-images/ubuntu-docker-images/+git/grafana:7.2-20.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+403981@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 :

Hi Sergio, Thanks for this MP!

LGTM

This was tested by running the new RUN command locally and verifying the snap fs was sane. Then, I proceeded to substitute the new dpkg command by different architectures to verify that the contents of the snap carried the contents for the correct arch.

$ file ppc/bin/grafana-server
ppc/bin/grafana-server: ELF 64-bit LSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), dynamically linked, interpreter /lib64/ld64.so.2, BuildID[sha1]=b863cb06e1ec833aa707c19f083f32a369b1df10, for GNU/Linux 3.10.0, not stripped

$ file x86/bin/grafana-server
x86/bin/grafana-server: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=85aefd05403517e313435a25efbe18a909777690, for GNU/Linux 3.2.0, 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 17ea8db..441e400 100644
3--- a/Dockerfile
4+++ b/Dockerfile
5@@ -13,7 +13,7 @@ RUN apt-get update && \
6
7 # taken from https://snapcraft.io/docs/build-on-docker
8 # Alternatively, we can install snapd, and issue `snap download grafana`
9-RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/grafana?channel=20.04/edge' | jq '.download_url' -r) --output grafana.snap
10+RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' -H "X-Ubuntu-Architecture: $(dpkg --print-architecture)" 'https://api.snapcraft.io/api/v1/snaps/details/grafana?channel=20.04/edge' | jq '.download_url' -r) --output grafana.snap
11
12 RUN mkdir -p /snap && unsquashfs -d /snap/grafana grafana.snap
13

Subscribers

People subscribed via source and target branches

to all changes: