observabilitystack / geoip-api

A JSON REST API for Maxmind GeoIP databases
https://observabilitystack.org
Apache License 2.0
43 stars 12 forks source link

Fails to start in minikube with "does not support all ... CPU features" / "Please rebuild the executable" #166

Open dfuhry opened 10 months ago

dfuhry commented 10 months ago

The image runs fine for me in docker, with command: docker run --rm -it ghcr.io/observabilitystack/geoip-api:latest.

However, when I try to run in minikube (kubernetes), with command: kubectl create deployment --image ghcr.io/observabilitystack/geoip-api:latest geoip-test1

The pod terminates immediately in error, producing only the output:

The current machine does not support all of the following CPU features that are required by the image: [CX8, CMOV, FXSR, MMX, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, POPCNT, LZCNT, AVX, AVX2, BMI1, BMI2, FMA].
Please rebuild the executable with an appropriate setting of the -march option.

In a full (non-minikube) kubernetes cluster when trying to run an older (2023-06) image, it terminates immediately with error:

/srv/geoip-api: CPU ISA level is lower than required

Suggestions online range from those related to the first error, e.g. "change -march=native to -march=x86-64", to running with different versions of libc. Are there any suggested workarounds to, or possible fixes for, the above errors?

dfuhry commented 10 months ago

I notice in the Dockerfile that the mvn command seems to specify build architecture native:

https://github.com/observabilitystack/geoip-api/blob/master/Dockerfile#L11C1-L11C1

The Graalvm JDK 17 release notes in the third bullet mention:

"Use -march=compatibility for best compatibility or -march=native for best performance if a native executable is deployed on the same machine or on a machine with the same CPU features." https://www.graalvm.org/release-notes/JDK_17/

If this is indeed the issue I'm experiencing, then it seems adding a "compatibility" variant image, or switching builds to "compatibility" if there is no noticeable performance difference, would resolve it.

dfuhry commented 10 months ago

I built the project locally and was able to run the image in both docker and minikube.

However, I noticed among my build output, the line:

#11 27.20 Warning: The host machine does not support all features of 'x86-64-v3'. Falling back to '-march=compatibility' for best compatibility.

So the architecture of the built image can depend on that of the machine that builds it, at least in this case. My guess is that the above fallback does not happen on the machine that builds the published geoip-api images.

tboeghk commented 9 months ago

I'll change to build args. Thanks for the find!

tboeghk commented 9 months ago

Thanks for the PR! Accepted and I re-triggered todays release build. You should be able to use the release in approx. 1h.