confluent-kafka-go: 1.4.0: Building apps fails on latest alpine, when using bundled librdkafka
Description
When using the 1.4.0 release, the bundled librdkafka fails to work as intended with the latest alpine.
How to reproduce
Build an application which uses github.com/confluentinc/confluent-kafka-go, in a container, using the alpine:3.11 image (which, at the time of writing, is actually alpine:3.11.5) as a base. Errors such as the following will be displayed:
go: downloading github.com/confluentinc/confluent-kafka-go v1.4.0
# github.com/confluentinc/confluent-kafka-go/kafka
/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.4.0/kafka/librdkafka/librdkafka_glibc_linux.a(rdkafka_txnmgr.o): in function `rd_kafka_txn_set_fatal_error':
(.text+0x141): undefined reference to `__strdup'
/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/pkg/mod/github.com/confluentinc/confluent-kafka-go@v1.4.0/kafka/librdkafka/librdkafka_glibc_linux.a(rdkafka_txnmgr.o): in function `rd_kafka_txn_set_abortable_error':
(.text+0x64f): undefined reference to `__strdup'
...
Installing a fresh build of librdkafka 1.4.0 into the container and building the application with -tags dynamic resolves the issue.
Could possibly be because the bundled librdkafka was built from a :edge release of alpine, instead of :latest?
Checklist
Please provide the following information:
- confluent-kafka-go and librdkafka version (
LibraryVersion()): 1.4.0, bundled. - Apache Kafka broker version: N/A
- Client configuration: N/A
- Operating system: Alpine Linux
- Provide client logs (with
"debug": ".."as necessary): N/A - Provide broker log excerpts: N/A
- Critical issue: No
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 28 (7 by maintainers)
You might need
-tags muslon those commands too.Ok seems like this works:
e.g. I think the key points:
CGO_ENABLEDflag@bschofield Did you build your application with
-tags musl? It seems like it is linking the glibc librdkafka (which references __strdup).Along these same lines, I can confirm that this worked with
golang:1.13.10-alpine3.10as my builder_base image with librdkafka v1.3.0.But as soon as I switch to 1.4.0 of confluent-kafka-go, and librdkafka, I get the below error:
Here’s the base image with the updated versions… For the working version, just substitute the docker image to
golang:1.13.10-apine3.11, librdkafkav1.3.0.I am facing the same issue, from the container I can run
go build -a -tags musland it works fine, butgo test ./... -tags muslfails just as as @bulletblp4 …what I am missing ?
Fixed by creating a static link
After following @lifeofguenter I was able to build but not run the file.
I get the following error on running the file.
I am getting:
when building:
I ended up getting past this by continuing to copy the ca-certificates into the docker image as I mentioned earlier, and then making sure the consumer set:
ssl.ca.location=/etc/ssl/certs/ca-certificates.crtSetting this prior to 1.4.0 was not needed, and instead was able to find the ssl ca on its own.
@edenhill Thanks for the fast response!
I did not use
-tags musl. Using-tags musldoes indeed fix the issue.Would it be useful to include a comment about the need to add
-tags muslfor alpine builds, in https://github.com/confluentinc/confluent-kafka-go/blob/master/README.md#install-the-client? At the moment I see that you do mention it in a separate repo (https://github.com/confluentinc/confluent-kafka-go-example/blob/master/README.md), but you don’t mention it in the main repo README.similar issue here
from golang:1.14.2 I also can’t install librdkafka 1.4.0 from deb using this manual https://docs.confluent.io/current/installation/installing_cp/deb-ubuntu.html#systemd-ubuntu-debian-install
Result in: