Skip to content

Commit 4bceccc

Browse files
Update docker-otelcol for multiarch builds (#4908)
1 parent 2d91f06 commit 4bceccc

File tree

5 files changed

+278
-72
lines changed

5 files changed

+278
-72
lines changed

.github/workflows/integration-test.yml

Lines changed: 85 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,14 @@ concurrency:
2626
env:
2727
GO_VERSION: "1.21.10"
2828
jobs:
29-
docker-otelcol:
30-
name: docker-otelcol
31-
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
29+
agent-bundle-linux:
3230
runs-on: ubuntu-20.04
3331
strategy:
3432
matrix:
3533
ARCH: [ "amd64", "arm64" ]
34+
fail-fast: false
3635
steps:
3736
- uses: actions/checkout@v4
38-
with:
39-
fetch-depth: 0
40-
- uses: actions/setup-go@v5
41-
with:
42-
go-version: ${{ env.GO_VERSION }}
43-
cache-dependency-path: '**/go.sum'
4437
- uses: actions/cache@v4
4538
id: bundle-cache
4639
with:
@@ -53,16 +46,80 @@ jobs:
5346
with:
5447
platforms: ${{ matrix.ARCH }}
5548
image: tonistiigi/binfmt:qemu-v7.0.0
56-
- run: |
57-
make docker-otelcol ARCH=${{ matrix.ARCH }}
49+
- run: make -C internal/signalfx-agent/bundle agent-bundle-linux ARCH=${{ matrix.ARCH }}
5850
env:
59-
DOCKER_BUILDKIT: '1'
6051
BUNDLE_CACHE_HIT: "${{ steps.bundle-cache.outputs.cache-hit }}"
61-
- run: docker save -o ./bin/image.tar otelcol:latest
6252
- uses: actions/upload-artifact@v4
6353
with:
64-
name: otelcol-${{ matrix.ARCH }}
54+
name: agent-bundle-linux-${{ matrix.ARCH }}
55+
path: ./dist/agent-bundle_linux_${{ matrix.ARCH }}.tar.gz
56+
57+
docker-otelcol:
58+
name: docker-otelcol
59+
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
60+
runs-on: ubuntu-20.04
61+
needs: agent-bundle-linux
62+
services:
63+
# Start a local registry for pushing the multiarch manifest and images
64+
registry:
65+
image: registry:2
66+
ports:
67+
- 5000:5000
68+
steps:
69+
# Multiarch images require more disk space
70+
- uses: jlumbroso/[email protected]
71+
- uses: actions/checkout@v4
72+
with:
73+
fetch-depth: 0
74+
- uses: actions/setup-go@v5
75+
with:
76+
go-version: ${{ env.GO_VERSION }}
77+
cache-dependency-path: '**/go.sum'
78+
- uses: actions/download-artifact@v4
79+
with:
80+
name: agent-bundle-linux-amd64
81+
path: ./dist
82+
- uses: actions/download-artifact@v4
83+
with:
84+
name: agent-bundle-linux-arm64
85+
path: ./dist
86+
- uses: docker/setup-qemu-action@v3
87+
with:
88+
platforms: arm64,ppc64le
89+
image: tonistiigi/binfmt:qemu-v7.0.0
90+
- uses: docker/setup-buildx-action@v3
91+
id: multiarch-otelcol-builder
92+
with:
93+
driver: docker-container # Create a builder with the docker-container driver required for multiarch builds
94+
driver-opts: network=host # Required for the builder to push to the local registry service
95+
- run: make docker-otelcol SKIP_BUNDLE=true ARCH=amd64,arm64,ppc64le IMAGE_NAME=localhost:5000/otelcol IMAGE_TAG=latest PUSH=true
96+
env:
97+
MULTIARCH_OTELCOL_BUILDER: ${{ steps.multiarch-otelcol-builder.outputs.name }} # Use the builder created by the docker/setup-buildx-action step
98+
- name: Save image archive for each platform to be loaded by downstream jobs
99+
run: |
100+
for arch in "amd64" "arm64" "ppc64le"; do
101+
mkdir -p docker-otelcol/${arch}
102+
docker pull --platform=linux/${arch} localhost:5000/otelcol:latest
103+
docker tag localhost:5000/otelcol:latest otelcol:latest
104+
docker save -o ./docker-otelcol/${arch}/image.tar otelcol:latest
105+
docker rmi -f localhost:5000/otelcol:latest otelcol:latest
106+
done
107+
- uses: actions/upload-artifact@v4
108+
with:
109+
name: otelcol
65110
path: ./bin
111+
- uses: actions/upload-artifact@v4
112+
with:
113+
name: docker-otelcol-amd64
114+
path: ./docker-otelcol/amd64
115+
- uses: actions/upload-artifact@v4
116+
with:
117+
name: docker-otelcol-arm64
118+
path: ./docker-otelcol/arm64
119+
- uses: actions/upload-artifact@v4
120+
with:
121+
name: docker-otelcol-ppc64le
122+
path: ./docker-otelcol/ppc64le
66123

67124
integration-vet:
68125
name: integration-vet
@@ -83,14 +140,19 @@ jobs:
83140
cache-dependency-path: '**/go.sum'
84141
- uses: actions/download-artifact@v4
85142
with:
86-
name: otelcol-${{ matrix.ARCH }}
143+
name: otelcol
87144
path: ./bin
145+
- uses: actions/download-artifact@v4
146+
with:
147+
name: docker-otelcol-${{ matrix.ARCH }}
148+
path: ./docker-otelcol/${{ matrix.ARCH }}
88149
- uses: docker/setup-qemu-action@v3
89150
if: ${{ matrix.ARCH != 'amd64' }}
90151
with:
91152
platforms: ${{ matrix.ARCH }}
92153
image: tonistiigi/binfmt:qemu-v7.0.0
93-
- run: docker load -i ./bin/image.tar
154+
- run: docker load -i ./docker-otelcol/${{ matrix.ARCH }}/image.tar
155+
- run: ln -sf otelcol_linux_${{ matrix.ARCH }} ./bin/otelcol
94156
- run: chmod a+x ./bin/*
95157
- run: make integration-vet
96158
env:
@@ -129,14 +191,19 @@ jobs:
129191
cache-dependency-path: '**/go.sum'
130192
- uses: actions/download-artifact@v4
131193
with:
132-
name: otelcol-${{ matrix.ARCH }}
194+
name: otelcol
133195
path: ./bin
196+
- uses: actions/download-artifact@v4
197+
with:
198+
name: docker-otelcol-${{ matrix.ARCH }}
199+
path: ./docker-otelcol/${{ matrix.ARCH }}
134200
- uses: docker/setup-qemu-action@v3
135201
if: ${{ matrix.ARCH != 'amd64' }}
136202
with:
137203
platforms: ${{ matrix.ARCH }}
138204
image: tonistiigi/binfmt:qemu-v7.0.0
139-
- run: docker load -i ./bin/image.tar
205+
- run: docker load -i ./docker-otelcol/${{ matrix.ARCH }}/image.tar
206+
- run: ln -sf otelcol_linux_${{ matrix.ARCH }} ./bin/otelcol
140207
- run: chmod a+x ./bin/*
141208
- uses: shogo82148/actions-setup-redis@v1
142209
if: matrix.PROFILE == 'integration'

.github/workflows/linux-package-test.yml

Lines changed: 87 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
- '.github/workflows/linux-package-test.yml'
1010
- 'cmd/otelcol/**'
1111
- 'internal/buildscripts/packaging/collect-libs.sh'
12+
- 'internal/buildscripts/packaging/docker-otelcol.sh'
1213
- 'internal/buildscripts/packaging/fpm/**'
1314
- 'internal/buildscripts/packaging/installer/install.sh'
1415
- 'internal/buildscripts/packaging/jmx-metric-gatherer-release.txt'
@@ -255,52 +256,117 @@ jobs:
255256
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
256257
runs-on: ubuntu-20.04
257258
needs: [cross-compile, agent-bundle-linux]
258-
strategy:
259-
matrix:
260-
ARCH: [ "amd64", "arm64", "ppc64le" ]
261-
fail-fast: false
262259
steps:
260+
# Multiarch images require more disk space
261+
- uses: jlumbroso/[email protected]
262+
263263
- name: Check out the codebase.
264264
uses: actions/checkout@v4
265265

266+
# Required to export a multiarch manifest and images to the local image store
267+
- name: Set up containerd image store
268+
uses: crazy-max/ghaction-setup-docker@v3
269+
with:
270+
daemon-config: |
271+
{
272+
"features": {
273+
"containerd-snapshotter": true
274+
}
275+
}
276+
266277
- name: Set up Go
267278
uses: actions/setup-go@v5
268279
with:
269280
go-version: ${{ env.GO_VERSION }}
270281
cache-dependency-path: '**/go.sum'
271282

272283
- name: Set up QEMU
273-
if: ${{ matrix.ARCH != 'amd64' }}
274284
uses: docker/setup-qemu-action@v3
275285
with:
276-
platforms: ${{ matrix.ARCH }}
286+
platforms: arm64,ppc64le
277287
image: tonistiigi/binfmt:qemu-v7.0.0
278288

279-
- name: Downloading binaries-linux_${{ matrix.ARCH }}
289+
- name: Downloading binaries-linux_amd64
280290
uses: actions/download-artifact@v4
281291
with:
282-
name: binaries-linux_${{ matrix.ARCH }}
292+
name: binaries-linux_amd64
293+
path: ./bin
294+
295+
- name: Downloading binaries-linux_arm64
296+
uses: actions/download-artifact@v4
297+
with:
298+
name: binaries-linux_arm64
299+
path: ./bin
300+
301+
- name: Downloading binaries-linux_ppc64le
302+
uses: actions/download-artifact@v4
303+
with:
304+
name: binaries-linux_ppc64le
283305
path: ./bin
284306

285307
- uses: actions/download-artifact@v4
286-
if: ${{ matrix.ARCH != 'ppc64le' }}
287308
with:
288-
name: agent-bundle-linux-${{ matrix.ARCH }}
309+
name: agent-bundle-linux-amd64
289310
path: ./dist
290311

291-
- name: Build ${{ matrix.ARCH }} docker image
292-
run: |
293-
make docker-otelcol SKIP_COMPILE=true SKIP_BUNDLE=true ARCH=${{ matrix.ARCH }}
312+
- uses: actions/download-artifact@v4
313+
with:
314+
name: agent-bundle-linux-arm64
315+
path: ./dist
294316

295-
- name: Check image arch
296-
run: |
297-
# ensure that the arch in the image manifest is correct
298-
[ "$( docker inspect --format='{{.Architecture}}' otelcol:${{ matrix.ARCH }} )" = "${{ matrix.ARCH }}" ] || exit 1
317+
- name: Build the multiarch docker image
318+
run: make docker-otelcol SKIP_COMPILE=true SKIP_BUNDLE=true ARCH=amd64,arm64,ppc64le
319+
320+
- name: Save the multiarch image archive to be loaded by downstream jobs
321+
run: mkdir -p docker-otelcol && docker save -o ./docker-otelcol/image.tar otelcol:latest
322+
323+
- uses: actions/upload-artifact@v4
324+
with:
325+
name: otelcol
326+
path: ./docker-otelcol
327+
328+
docker-otelcol-verify:
329+
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
330+
runs-on: ubuntu-20.04
331+
needs: [docker-otelcol]
332+
strategy:
333+
matrix:
334+
ARCH: [ "amd64", "arm64", "ppc64le" ]
335+
fail-fast: false
336+
steps:
337+
- name: Check out the codebase.
338+
uses: actions/checkout@v4
339+
340+
# Required to load a multiarch archive to the local image store
341+
- name: Set up containerd image store
342+
uses: crazy-max/ghaction-setup-docker@v3
343+
with:
344+
daemon-config: |
345+
{
346+
"features": {
347+
"containerd-snapshotter": true
348+
}
349+
}
350+
351+
- name: Set up QEMU
352+
if: ${{ matrix.ARCH != 'amd64' }}
353+
uses: docker/setup-qemu-action@v3
354+
with:
355+
platforms: ${{ matrix.ARCH }}
356+
image: tonistiigi/binfmt:qemu-v7.0.0
357+
358+
- uses: actions/download-artifact@v4
359+
with:
360+
name: otelcol
361+
path: ./docker-otelcol
362+
363+
- name: Load multiarch docker image
364+
run: docker load -i ./docker-otelcol/image.tar
299365

300366
- name: Run docker image
301367
run: |
302368
# ensure the collector can start with the default config file
303-
docker run --platform linux/${{ matrix.ARCH }} -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol:${{ matrix.ARCH }}
369+
docker run --platform linux/${{ matrix.ARCH }} -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol:latest
304370
sleep 10
305371
if [ -z "$( docker ps --filter=status=running --filter=name=otelcol -q )" ]; then
306372
docker logs otelcol
@@ -320,7 +386,7 @@ jobs:
320386
exit 1
321387
fi
322388
for config in $configs; do
323-
docker run --platform linux/${{ matrix.ARCH }} -d -e SPLUNK_CONFIG=/etc/otel/collector/${config} -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol:${{ matrix.ARCH }}
389+
docker run --platform linux/${{ matrix.ARCH }} -d -e SPLUNK_CONFIG=/etc/otel/collector/${config} -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol:latest
324390
sleep 10
325391
if [ -z "$( docker ps --filter=status=running --filter=name=otelcol -q )" ]; then
326392
docker logs otelcol
@@ -333,15 +399,15 @@ jobs:
333399
- name: Check journalctl
334400
run: |
335401
# ensure journalctl can run with the collected libraries
336-
docker run --platform linux/${{ matrix.ARCH }} -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol:${{ matrix.ARCH }}
402+
docker run --platform linux/${{ matrix.ARCH }} -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol:latest
337403
docker exec otelcol /bin/journalctl
338404
docker rm -f otelcol
339405
340406
- name: Check python and java
341407
if: ${{ matrix.ARCH != 'ppc64le' }}
342408
run: |
343409
# ensure python and java can run with the collected libraries
344-
docker run --platform linux/${{ matrix.ARCH }} -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol:${{ matrix.ARCH }}
410+
docker run --platform linux/${{ matrix.ARCH }} -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol:latest
345411
docker exec otelcol /usr/lib/splunk-otel-collector/agent-bundle/bin/python --version
346412
docker exec otelcol /usr/lib/splunk-otel-collector/agent-bundle/jre/bin/java -version
347413
# ensure collectd-python plugins were installed

Makefile

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,7 @@ delete-tag:
148148

149149
.PHONY: docker-otelcol
150150
docker-otelcol:
151-
ifneq ($(SKIP_COMPILE), true)
152-
$(MAKE) binaries-linux_$(ARCH)
153-
endif
154-
ifneq ($(filter $(ARCH), $(BUNDLE_SUPPORTED_ARCHS)),)
155-
ifneq ($(SKIP_BUNDLE), true)
156-
$(MAKE) -C internal/signalfx-agent/bundle agent-bundle-linux ARCH=$(ARCH) DOCKER_REPO=$(DOCKER_REPO)
157-
endif
158-
endif
159-
rm -rf ./cmd/otelcol/dist
160-
mkdir -p ./cmd/otelcol/dist
161-
cp ./bin/otelcol_linux_$(ARCH) ./cmd/otelcol/dist/otelcol
162-
cp ./bin/migratecheckpoint_linux_$(ARCH) ./cmd/otelcol/dist/migratecheckpoint
163-
cp ./internal/buildscripts/packaging/collect-libs.sh ./cmd/otelcol/dist/collect-libs.sh
164-
ifneq ($(filter $(ARCH), $(BUNDLE_SUPPORTED_ARCHS)),)
165-
cp ./dist/agent-bundle_linux_$(ARCH).tar.gz ./cmd/otelcol/dist/agent-bundle.tar.gz
166-
endif
167-
docker buildx build --platform linux/$(ARCH) -o type=image,name=otelcol:$(ARCH),push=false --build-arg ARCH=$(ARCH) --build-arg DOCKER_REPO=$(DOCKER_REPO) --build-arg JMX_METRIC_GATHERER_RELEASE=$(JMX_METRIC_GATHERER_RELEASE) ./cmd/otelcol/
168-
docker tag otelcol:$(ARCH) otelcol:latest
169-
rm -rf ./cmd/otelcol/dist
151+
ARCH=$(ARCH) SKIP_COMPILE=$(SKIP_COMPILE) SKIP_BUNDLE=$(SKIP_BUNDLE) DOCKER_REPO=$(DOCKER_REPO) JMX_METRIC_GATHERER_RELEASE=$(JMX_METRIC_GATHERER_RELEASE) ./internal/buildscripts/packaging/docker-otelcol.sh
170152

171153
.PHONY: binaries-all-sys
172154
binaries-all-sys: binaries-darwin_amd64 binaries-darwin_arm64 binaries-linux_amd64 binaries-linux_arm64 binaries-windows_amd64 binaries-linux_ppc64le

0 commit comments

Comments
 (0)