hoonmin / influxdb-collectd-proxy

A very simple proxy between collectd and influxdb.
MIT License
72 stars 26 forks source link

Make fails to include Influxdb classes #31

Open donpdonp opened 9 years ago

donpdonp commented 9 years ago
$ make
GOPATH=:`pwd` go get github.com/paulhammond/gocollectd
GOPATH=:`pwd` go get github.com/influxdb/influxdb/client
GOPATH=:`pwd` go build -o bin/influxdb-collectd-proxy
# _/home/devops/dashboard/influxdb-collectd-proxy
./influxdb-collectd-proxy.go:120: undefined: client.ClientConfig
./influxdb-collectd-proxy.go:142: undefined: client.Series
yanfali commented 9 years ago

Hi Don,

I think you need to download, install and run godeps: https://github.com/tools/godep

The proxy uses an older version of the influxdb client library and hasn't been updated to the latest version and some of the APIs have been deprecated.

donpdonp commented 9 years ago

Hi- I tried adopting the pull request for godep - got the same failure.

$ make
GOPATH=:`pwd` go get github.com/tools/godep
GOPATH=:`pwd` bin/godep restore
GOPATH=:`pwd` go build -o bin/influxdb-collectd-proxy
# _/home/devops/dashboard/influxdb-collectd-proxy
./influxdb-collectd-proxy.go:120: undefined: client.ClientConfig
./influxdb-collectd-proxy.go:142: undefined: client.Series
yanfali commented 9 years ago

Let me give it a shot. I normally don't use the makefile.

yanfali commented 9 years ago

OK, that was interesting. It built for me, but I have godeps setup from before... Let me try blowing away all my upstream.

yanfali commented 9 years ago

So I blew away my upstream then I typed make and it failed. Then I typed godep restore and then typed make and it worked. So the steps are valid. Let me try using the Makefile.

yanfali commented 9 years ago

OK, this make file is kind of hokey. Why does it mess with the GOPATH? For one thing setting the GOPATH means that your src downloads are going to end up in wacky places. Don, can you just try install godep into your GOPATH environment and ignoring the makefile to see if it works?

donpdonp commented 9 years ago

Hi. I'd say Go is hokey and the makefile is trying to compensate. I'd like to keep dependencies local to the project folder and GOPATH=pwd appears to be doing that. Running godep and go build from the command line produces the same result. The influxdb package is there, go isnt finding it.

~/dashboard/influxdb-collectd-proxy$ GOPATH=`pwd` go build
# _/home/devops/dashboard/influxdb-collectd-proxy
./influxdb-collectd-proxy.go:120: undefined: client.ClientConfig
./influxdb-collectd-proxy.go:142: undefined: client.Series
./influxdb-collectd-proxy.go:151: client.WriteSeries undefined (type *client.Client has no field or method WriteSeries)
./influxdb-collectd-proxy.go:157: undefined: client.Series
./influxdb-collectd-proxy.go:164: undefined: client.Series
./influxdb-collectd-proxy.go:169: undefined: client.Series
./influxdb-collectd-proxy.go:258: undefined: client.Series
~/dashboard/influxdb-collectd-proxy$ ls pkg/linux_amd64/github.com/
influxdb  kr  paulhammond
~/dashboard/influxdb-collectd-proxy$

Thanks for your help, I know this is a go setup issue and not specific to influxdb-collectd-proxy.

yanfali commented 9 years ago

Hi Don,

not disagreeing with you, just don't like it when things are messing with the GOPATH since it makes debugging much harder. What looks like is happening is the influxdb package that is being downloaded has the wrong git rev. Can you verify that the the GOPATH version of influxdb has the correct version? This may just be a bug in godep because it can't handle this use case.

If you look in Godeps/Godeps.json

The rev is a0fd0cd03efd284fed64bb598f9c1e5fa1d984e5

If they don't match in your GOPATH/src/github.com/influxdb/influxdb this is never going to work :(

See if I git log my copy on regular GOPATH:

git log

commit a0fd0cd03efd284fed64bb598f9c1e5fa1d984e5 Author: Todd Persen todd.persen@gmail.com Date: Sun Nov 16 00:49:32 2014 -0500

Update CHANGELOG for v0.8.6

That's the version that should be checked out. Hope this helps.

Yan

On Tue, Apr 28, 2015 at 8:49 AM, Don Park notifications@github.com wrote:

Hi. I'd say Go is hokey and the makefile is trying to compensate. I'd like to keep dependencies local to the project folder and GOPATH=pwd appears to be doing that. Running godep and go build from the command line produces the same result. The influxdb package is there, go isnt finding it.

~/dashboard/influxdb-collectd-proxy$ GOPATH=pwd go build

_/home/devops/dashboard/influxdb-collectd-proxy

./influxdb-collectd-proxy.go:120: undefined: client.ClientConfig ./influxdb-collectd-proxy.go:142: undefined: client.Series ./influxdb-collectd-proxy.go:151: client.WriteSeries undefined (type *client.Client has no field or method WriteSeries) ./influxdb-collectd-proxy.go:157: undefined: client.Series ./influxdb-collectd-proxy.go:164: undefined: client.Series ./influxdb-collectd-proxy.go:169: undefined: client.Series ./influxdb-collectd-proxy.go:258: undefined: client.Series ~/dashboard/influxdb-collectd-proxy$ ls pkg/linux_amd64/github.com/ influxdb kr paulhammond ~/dashboard/influxdb-collectd-proxy$

Thanks for your help, I know this is a go setup issue and not specific to influxdb-collectd-proxy.

— Reply to this email directly or view it on GitHub https://github.com/hoonmin/influxdb-collectd-proxy/issues/31#issuecomment-97112186 .

"We do not learn so much by our successes as we learn by failures -- our own and others'. Especially if we see the failures properly corrected." -- Frank Lloyd Wright

yanfali commented 9 years ago

Don, I reworked the makefile a little bit to get the isolation you were after and now it mostly works. It's a bit hacky:

PWD := $(shell pwd)
GOPATH := $(PWD)/build

all: clean build

build:
    GOPATH=$(GOPATH) go get github.com/tools/godep
    GOPATH=$(GOPATH) $(GOPATH)/bin/godep restore
    GOPATH=$(GOPATH) go build -o $(GOPATH)/bin/influxdb-collectd-proxy

clean: 
    rm -rf $(GOPATH)

Everything will be isolated under the build directory, including the check outs, so this won't affect your other GOPATH projects. Give it a shot and let me know.

sargon commented 9 years ago

That fixed the problem for me.