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

Mage Error #6

Open
hoptical opened this issue Nov 8, 2021 · 2 comments · Fixed by #25
Open

Mage Error #6

hoptical opened this issue Nov 8, 2021 · 2 comments · Fixed by #25
Labels
bug Something isn't working

Comments

@hoptical
Copy link
Owner

hoptical commented Nov 8, 2021

Running mage command faces bellow error:

$ mage build:backend -v
# github.com/grafana/grafana-starter-datasource-backend/pkg/kafka_helper
pkg/kafka_helper/client.go:12:12: undefined: kafka.Consumer
pkg/kafka_helper/client.go:15:48: undefined: kafka.Consumer
pkg/kafka_helper/client.go:17:25: undefined: kafka.NewConsumer
pkg/kafka_helper/client.go:17:44: undefined: kafka.ConfigMap
pkg/kafka_helper/client.go:42:50: undefined: kafka.Event
pkg/kafka_helper/client.go:50:8: undefined: kafka.Message
pkg/kafka_helper/client.go:53:7: undefined: kafka.Error
pkg/kafka_helper/client.go:60:18: undefined: kafka.ErrAllBrokersDown
Error: running "go build -o dist/gpx_kafka-datasource_linux_amd64 -ldflags -w -s -extldflags "-static" -X 'main.commit=efe069bd4332485c723ec3c23116b6eaf04d918e' -X 'github.com/grafana/grafana-plugin-sdk-go/build.buildInfoJSON={"time":1636410898742,"version":"1.0.0","repo":"git@github.com:exaco/kafka-datasource.git","branch":"main","hash":"efe069bd4332485c723ec3c23116b6eaf04d918e"}' -X 'main.version=1.0.0' -X 'main.branch=main' ./pkg" failed with exit code 2

But its ok with the direct go build command and Grafana works with it successfully:
go build -o dist/gpx_kafka-datasource_linux_amd64 ./pkg

@hoptical hoptical added the bug Something isn't working label Nov 8, 2021
@marcusolsson
Copy link

I think you need to:

  1. Update the package name in the go.mod file.
  2. It seems like the kafka package requires cgo, to you'll need to enable it as well. Add the following to your Magefile.go:
var _ = build.SetBeforeBuildCallback(func(cfg build.Config) (build.Config, error) {
	cfg.EnableCGo = true
	return cfg, nil
})

Also looks like the kafka package isn't supported on Windows, so you might have some trouble building the Windows binary.

@hoptical
Copy link
Owner Author

@marcusolsson Thanks for your answer.
Yes, It worked after your suggested modifications.
So according to this link, we've below considerations with confluent-kafka-go package:

  • To have GSSAPI/Kerberos authentication support, librdkafka should be installed separately and then build with -tags dynamic. Which I guess it's not applicable with the mage command and we've to use go build -tags dynamic -o dist/gpx_kafka-datasource_linux_amd64 ./pkg
  • As you said the package doesn't support windows.
  • For other operating systems like MacOSX, builds should be taken on the same OS and it's not feasible on Linux.

However, in future, we'll consider changing to other packages such as kafka-go or goka.

@hoptical hoptical linked a pull request Nov 17, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants