Skip to content

Commit 24f81a2

Browse files
harelmo-lumigoCircleCI
and
CircleCI
authored
fix: make the collector architecture match the image architecture (#154)
Co-authored-by: CircleCI <[email protected]>
1 parent 8ea3336 commit 24f81a2

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ workflows:
2424

2525
- lumigo-orb/prep-it-resources:
2626
context: common
27+
venv_python_version: "3.9"
2728
requires:
2829
- lumigo-orb/is_environment_available
2930

.github/workflows/build-test-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ jobs:
569569
env:
570570
PROXY_IMG: ${{ matrix.ecr-registry }}/lumigo/lumigo-kubernetes-telemetry-proxy:${{ needs.validate-release-increment.outputs.version }}
571571
run: |
572-
make docker-buildx-telemetry-proxy
572+
make verify-telemetry-proxy-arch docker-buildx-telemetry-proxy
573573
574574
publish-watchdog-ecr-image:
575575
strategy:

Makefile

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ ENVTEST_K8S_VERSION = 1.28.0
1515

1616
GOCMD?= go
1717

18+
POST_BUILD_FLAG ?= --push
19+
1820
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
1921
ifeq (,$(shell $(GOCMD) env GOBIN))
2022
GOBIN=$(shell $(GOCMD)go env GOPATH)/bin
@@ -122,7 +124,10 @@ docker-push: ## Push docker image with the manager.
122124
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
123125
# - be able to push the image for your registry (i.e. if you do not inform a valid value via CONTROLLER_IMG=<myregistry/image:<tag>> than the export will fail)
124126
# To properly provided solutions that supports more than one platform you should use this option.
125-
PLATFORMS ?= linux/arm64,linux/amd64 #,linux/s390x,linux/ppc64le
127+
PLATFORM_ARRAY := linux/arm64 linux/amd64 # linux/s390x linux/ppc64le
128+
# Convert the array to a comma-separated string for docker buildx
129+
PLATFORMS ?= $(shell echo $(PLATFORM_ARRAY) | sed 's/ /,/g')
130+
126131
.PHONY: docker-buildx
127132
docker-buildx: test docker-buildx-manager docker-buildx-telemetry-proxy docker-buildx-watchdog ## Build and push docker image for the manager for cross-platform support
128133

@@ -136,15 +141,33 @@ docker-buildx-manager: ## Build and push docker image for the manager for cross-
136141
docker buildx rm project-v3-builder && \
137142
rm Dockerfile.cross )
138143

144+
.PHONY: verify-telemetry-proxy-arch
145+
verify-telemetry-proxy-arch:
146+
@for platform in $(PLATFORM_ARRAY); do \
147+
arch=$$(echo $$platform | cut -d'/' -f2); \
148+
$(MAKE) docker-buildx-telemetry-proxy PLATFORMS=$$platform IMG_VERSION=${IMG_VERSION}-$$arch POST_BUILD_FLAG=--load; \
149+
image_arch=$$(docker inspect ${PROXY_IMG}-$$arch | jq -r '.[] | select(.RepoTags[0] == "${PROXY_IMG}-'$$arch'") | .Architecture'); \
150+
file_output=$$(docker run --rm --entrypoint="" "${PROXY_IMG}-$$arch" sh -c "apk add --no-cache --quiet file >/dev/null 2>&1; file -b /lumigo/bin/otelcol"); \
151+
if [[ "$$arch" == "arm64" && ! "$$file_output" =~ ARM|aarch64 ]]; then \
152+
echo "Architecture mismatch: $$arch container should contain ARM binary but found: $$file_output"; \
153+
exit 1; \
154+
elif [[ "$$arch" == "amd64" && ! "$$file_output" =~ x86-64|x86_64|AMD64 ]]; then \
155+
echo "❌ Architecture mismatch: $$arch container should contain x86_64 binary but found: $$file_output"; \
156+
exit 1; \
157+
fi; \
158+
echo "✅ Architecture verification passed for $$arch"; \
159+
done
160+
139161
.PHONY: docker-buildx-telemetry-proxy
140162
docker-buildx-telemetry-proxy: ## Build and push docker image for the manager for cross-platform support
141-
( cd telemetryproxy && \
163+
(cd telemetryproxy && \
142164
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross && \
165+
docker buildx rm project-v3-builder >/dev/null 2>&1 || true && \
143166
docker buildx create --name project-v3-builder && \
144167
docker buildx use project-v3-builder && \
145-
docker buildx build --push --provenance=false --platform=$(PLATFORMS) --tag ${PROXY_IMG} -f Dockerfile.cross --build-arg "version=$(VERSION)" . && \
168+
docker buildx build $(POST_BUILD_FLAG) --provenance=false --platform=$(PLATFORMS) --tag ${PROXY_IMG} -f Dockerfile.cross --build-arg "version=$(VERSION)" . && \
146169
docker buildx rm project-v3-builder && \
147-
rm Dockerfile.cross )
170+
rm Dockerfile.cross)
148171

149172
.PHONY: docker-buildx-watchdog
150173
docker-buildx-watchdog: ## Build and push docker image for the watchdog for cross-platform support

telemetryproxy/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
FROM golang:1.23-alpine AS telemetry-proxy-builder
33

44
ARG version='dev'
5+
ARG TARGETOS
6+
ARG TARGETARCH
7+
58
ENV VERSION=${version}
69

710
RUN apk add --update make git
811

912
ADD ./src /src
1013
WORKDIR /src
1114

12-
RUN make VERSION=${VERSION} OTELCONTRIBCOL_FILENAME=otelcontribcol otelcontribcolbuilder
15+
RUN make VERSION=${VERSION} GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} OTELCONTRIBCOL_FILENAME=otelcontribcol otelcontribcolbuilder
1316

1417
# We need to chmod files to fit the expected uid and gid
1518
# at runtime. Since we do not want to depend on buildkit,

telemetryproxy/src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ otelcontribcolbuilder: install-tools $(BUILDER)
4949
# Split source generation and compilation in two steps, because the GOARCH and GOOS may be different when cross-compiling
5050
mkdir -p ./dist
5151
$(BUILDER) --skip-compilation --config ./builder/config.yaml --version $(VERSION)
52-
cd ./dist/ && GOOS= GOARCH= CGO_ENABLED=0 $(GOCMD) build -trimpath -o $(OTELCONTRIBCOL_FILENAME) \
52+
cd ./dist/ && GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 $(GOCMD) build -trimpath -o $(OTELCONTRIBCOL_FILENAME) \
5353
$(BUILD_INFO) -tags $(GO_BUILD_TAGS) .

0 commit comments

Comments
 (0)