Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build xk6-kafka using docker to build custom binaries #325

Open
beachwood23 opened this issue Feb 3, 2025 · 3 comments · May be fixed by #326
Open

Can't build xk6-kafka using docker to build custom binaries #325

beachwood23 opened this issue Feb 3, 2025 · 3 comments · May be fixed by #326
Labels
❓ Question Further information is requested

Comments

@beachwood23
Copy link

beachwood23 commented Feb 3, 2025

The Grafana xk6 documentation page describes this way to build a k6 binary with extensions:
https://grafana.com/docs/k6/latest/extensions/#xk6-makes-custom-binaries

You have two options for creating k6 binaries: using [Go and xk6](https://grafana.com/docs/k6/latest/extensions/build-k6-binary-using-go/) or [Docker](https://grafana.com/docs/k6/latest/extensions/build-k6-binary-using-docker/):

I am using several extensions, like xk6-file and also xk6-output-statsd. So, I want to be able to build a custom binary with these two extensions and also xk6-kafka.

When I run:

docker run --rm -e GOOS=darwin -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" \
  grafana/xk6 build \
  --with github.com/avitalique/xk6-file@latest \
  --with github.com/LeonAdato/xk6-output-statsd@latest \
  --with github.com/mostafa/xk6-kafka@latest

I see this failure:

2025/02/03 14:47:15 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod edit -require github.com/LeonAdato/xk6-output-statsd@latest
2025/02/03 14:47:15 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17
go: downloading github.com/LeonAdato/xk6-output-statsd v0.2.0
go: downloading github.com/DataDog/datadog-go v0.0.0-20180330214955-e67964b4021a
2025/02/03 14:47:16 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod edit -require github.com/mostafa/xk6-kafka@latest
2025/02/03 14:47:16 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17
go: downloading github.com/mostafa/xk6-kafka v0.30.0
go: github.com/mostafa/[email protected] requires go >= 1.23 (running go 1.22.7; GOTOOLCHAIN=local)
2025/02/03 14:47:16 [INFO] Cleaning up temporary folder: /tmp/buildenv_2025-02-03-1447.4082809804
2025/02/03 14:47:16 [FATAL] exit status 1

It looks like xk6-kafka requires a newer version of Go than is bundled with the Grafana xk6 docker image.

I would expect that this extension will support both ways of building that are specified in the Grafana docs.

It looks like this used to be supported, as Grafana references xk6-kafka in their docker image examples: https://hub.docker.com/r/grafana/xk6/

I can help make whatever updates necessary, if I am pointed in the right direction. Thank you!

@mostafa
Copy link
Owner

mostafa commented Feb 3, 2025

@beachwood23 Are you using the latest of version of Go loacally to build the extensions?

@beachwood23
Copy link
Author

Hi @mostaf , I think the point of using the docker containers to build is that we will not need Go installed locally at all.

After further research, it looks like this fix worked: grafana/xk6#122

After updating my docker image with docker pull grafana/k6, my initial command above worked.

One request that might fix this, would be to add a description in the README of how people can use the docker images to build xk6-kafka instead of using the local Go toolchain. I can draft this out soon, if you like.

@mostafa
Copy link
Owner

mostafa commented Feb 3, 2025

@beachwood23 Go for it!

@mostafa mostafa added the ❓ Question Further information is requested label Feb 3, 2025
@beachwood23 beachwood23 linked a pull request Feb 4, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ Question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants