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

"make package" broken for metricbeat based community beats #3296

Closed
fjgal opened this issue Jan 6, 2017 · 0 comments
Closed

"make package" broken for metricbeat based community beats #3296

fjgal opened this issue Jan 6, 2017 · 0 comments

Comments

@fjgal
Copy link
Contributor

fjgal commented Jan 6, 2017

See discuss for background information. @ruflin advised to create an issue for it

Note that is is only reproducible after applying workaround for #3294

When packaging a community beat based on metricbeat (make package) it fails with following error:

Execute /scripts/before_build.sh github.com/someuser/somebeat
install -d -m 755 /build/homedir/scripts/
install -m 755 ./vendor/github.com/elastic/beats/libbeat/scripts/migrate_beat_config_1_x_to_5_0.py /build/homedir/scripts/
Compiling import_dashboards for windows/amd64
Compiling import_dashboards for windows/386
Compiling import_dashboards for darwin/amd64
Cloning into '/go/src/github.com/tsg/gotpl'...
# disable the system/load metricset on windows
sed -i.bk 's/- load/#- load/' /build/metricbeat-win.yml
sed: can't read /build/metricbeat-win.yml: No such file or directory
make: *** [before-build] Error 2
make[1]: *** [prepare-package-cgo] Error 2
make: *** [package] Error 2

I tracked the problem down to metricbeat/Makefile (line 56-63):

# This is called by the beats packer before building starts
.PHONY: before-build
before-build:
	# disable the system/load metricset on windows
	sed -i.bk 's/- load/#- load/' $(PREFIX)/metricbeat-win.yml
	rm $(PREFIX)/metricbeat-win.yml.bk
	sed -i.bk 's/- load/#- load/' $(PREFIX)/metricbeat-win.full.yml
	rm $(PREFIX)/metricbeat-win.full.yml.bk

metricbeat/Makefile is included in the generated Makefile for the community beat, and when called it fails since the file metricbeat-win*.yml and metricbeat-win.full.yml don't exist for the community beat.

The sed commands should only be executed when packaging metricbeat and not for other beats based on it. A possible solution (probably not the cleanest) is to introduce a condition on the BEATNAME, changing the above lines to:

# This is called by the beats packer before building starts
.PHONY: before-build
before-build:
ifeq ($(BEATNAME), metricbeat)
        # disable the system/load metricset on windows
        sed -i.bk 's/- load/#- load/' $(PREFIX)/metricbeat-win.yml
        rm $(PREFIX)/metricbeat-win.yml.bk
        sed -i.bk 's/- load/#- load/' $(PREFIX)/metricbeat-win.full.yml
        rm $(PREFIX)/metricbeat-win.full.yml.bk
endif

This issue seems to be introduced by dd43dd1

I'll submit a PR with the changes described above.

Tested on 5b973a0
OS: Ubuntu 14.04
Steps to reproduce:

$ cd $GOPATH/src/github.com/someuser
$ cookiecutter $GOPATH/src/github.com/elastic/beats/generate/metricbeat/metricset
project_name [Examplebeat]: somebeat
github_name [your-github-name]: someuser
beat [somebeat]: somebeat
beat_path [github.com/someuser]: github.com/someuser
full_name [Firstname Lastname]: Some User

$ cd somebeat/
$ make setup
$ make update
$ make package
fjgal added a commit to fjgal/beats that referenced this issue Jan 6, 2017
metricbeat-win.yml and metricbeat-win.full.yml are modified only if BEATNAME is "metricbeat"

Fixes elastic#3296
ruflin pushed a commit that referenced this issue Jan 6, 2017
metricbeat-win.yml and metricbeat-win.full.yml are modified only if BEATNAME is "metricbeat"

Fixes #3296
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant