chop-dbhi / prometheus-sql

Service that exposes Prometheus metrics for a SQL result set.
BSD 2-Clause "Simplified" License
202 stars 55 forks source link

go: golang.org/x/net@v0.0.0-20200822124328-c89045814202: unrecognized import path "golang.org/x/net" (https fetch: Get https://golang.org/x/net?go-get=1: x509: certificate signed by unknown authority) #62

Closed mahmoud-mahdi closed 4 years ago

mahmoud-mahdi commented 4 years ago

I cannot build the app:

I tried to build it with the provided Dockerfile and i got the following error:

$ docker build -t prom/prometheus-sql .
Sending build context to Docker daemon  84.99kB
Step 1/14 : FROM golang:1.15.2 as builder
 ---> 05c8f6d2538a
Step 2/14 : RUN mkdir -p /go/src/app
 ---> Using cache
 ---> 76a33c7dc226
Step 3/14 : WORKDIR /go/src/app
 ---> Using cache
 ---> c1492556f44d
Step 4/14 : COPY . /go/src/app
 ---> Using cache
 ---> fb6afcd9765f
Step 5/14 : RUN go build -v .
 ---> Running in 2596fb8c6723
go: github.com/gogo/protobuf@v1.3.1: Get "https://proxy.golang.org/github.com/gogo/protobuf/@v/v1.3.1.mod": dial tcp 172.217.23.17:443: i/o timeout
The command '/bin/sh -c go build -v .' returned a non-zero code: 1

I tried to build it also local without docker and with my 'go version go1.13.6 linux/amd64' and got the same error

$ go build -v .
go: golang.org/x/net@v0.0.0-20200822124328-c89045814202: unrecognized import path "golang.org/x/net" (https fetch: Get https://golang.org/x/net?go-get=1: x509: certificate signed by unknown authority)

What should i do?

haxorof commented 4 years ago

Hi @mahmoud-mahdi , The timeout error and certificate error you got indicates there might be two different errors. I would recommend you to just start a container like "bash" and run wget with the URL you get the timeout on. If that fails then I might be some connectivity issue related to outgoing connections from a Docker network or in general. The second error you get indicates to me that go does not find your system CA certificates or similar problem. If you run wget or curl with the URL see you might get the same issue and then you will have to google how to fix that on your machine depending on what Linux distribution you use.

I did a test build locally and everything works as expected:

$ docker build -t prometheus-sql:master .
Sending build context to Docker daemon   12.9MB
Step 1/14 : FROM golang:1.15.2 as builder
1.15.2: Pulling from library/golang
57df1a1f1ad8: Pull complete 
71e126169501: Pull complete
1af28a55c3f3: Pull complete
03f1c9932170: Pull complete 
f4773b341423: Pull complete 
fb320882041b: Pull complete
24b0ad6f9416: Pull complete
Digest: sha256:da7ff43658854148b401f24075c0aa390e3b52187ab67cab0043f2b15e754a68
Status: Downloaded newer image for golang:1.15.2
 ---> 05c8f6d2538a
Step 2/14 : RUN mkdir -p /go/src/app
 ---> Running in 0b034dbdbf1a
Removing intermediate container 0b034dbdbf1a
 ---> 8b7adcd9f752
Step 3/14 : WORKDIR /go/src/app
 ---> Running in 95ab4b3d8d42
Removing intermediate container 95ab4b3d8d42
 ---> bc33b9e03f4e
Step 4/14 : COPY . /go/src/app
 ---> 2de35655eaec
Step 5/14 : RUN go build -v .
 ---> Running in ac2fbd96f12f
go: downloading golang.org/x/net v0.0.0-20200822124328-c89045814202
go: downloading github.com/jpillora/backoff v1.0.0
go: downloading github.com/prometheus/client_golang v1.7.1
go: downloading gopkg.in/tylerb/graceful.v1 v1.2.15
go: downloading gopkg.in/yaml.v2 v2.3.0
go: downloading github.com/prometheus/common v0.13.0
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/golang/protobuf v1.4.2
go: downloading github.com/cespare/xxhash/v2 v2.1.1
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/prometheus/procfs v0.1.3
go: downloading google.golang.org/protobuf v1.23.0
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.1
go: downloading golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae
google.golang.org/protobuf/internal/flags
google.golang.org/protobuf/internal/set
google.golang.org/protobuf/internal/fieldnum
github.com/jpillora/backoff
github.com/beorn7/perks/quantile
github.com/cespare/xxhash/v2
google.golang.org/protobuf/internal/detrand
google.golang.org/protobuf/internal/pragma
google.golang.org/protobuf/internal/genname
google.golang.org/protobuf/internal/errors
google.golang.org/protobuf/internal/version
github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg
github.com/prometheus/common/model
github.com/prometheus/procfs/internal/fs
google.golang.org/protobuf/encoding/protowire
github.com/prometheus/procfs/internal/util
golang.org/x/sys/internal/unsafeheader
golang.org/x/net/context
google.golang.org/protobuf/reflect/protoreflect
golang.org/x/sys/unix
gopkg.in/tylerb/graceful.v1
gopkg.in/yaml.v2
google.golang.org/protobuf/reflect/protoregistry
google.golang.org/protobuf/internal/strs
google.golang.org/protobuf/internal/encoding/text
google.golang.org/protobuf/internal/encoding/messageset
google.golang.org/protobuf/internal/mapsort
google.golang.org/protobuf/internal/fieldsort
google.golang.org/protobuf/runtime/protoiface
google.golang.org/protobuf/internal/descfmt
google.golang.org/protobuf/proto
google.golang.org/protobuf/internal/descopts
google.golang.org/protobuf/internal/encoding/defval
github.com/prometheus/procfs
google.golang.org/protobuf/encoding/prototext
google.golang.org/protobuf/internal/filedesc
google.golang.org/protobuf/internal/encoding/tag
google.golang.org/protobuf/internal/impl
google.golang.org/protobuf/internal/filetype
google.golang.org/protobuf/runtime/protoimpl
google.golang.org/protobuf/types/known/anypb
github.com/golang/protobuf/proto
google.golang.org/protobuf/types/known/durationpb
google.golang.org/protobuf/types/known/timestamppb
github.com/golang/protobuf/ptypes/any
github.com/golang/protobuf/ptypes/timestamp
github.com/golang/protobuf/ptypes/duration
github.com/matttproud/golang_protobuf_extensions/pbutil
github.com/golang/protobuf/ptypes
github.com/prometheus/client_model/go
github.com/prometheus/client_golang/prometheus/internal
github.com/prometheus/common/expfmt
github.com/prometheus/client_golang/prometheus
github.com/prometheus/client_golang/prometheus/promhttp
github.com/chop-dbhi/prometheus-sql/prometheus-sql/v2
Removing intermediate container ac2fbd96f12f
 ---> f0b87d3c2dc3
Step 6/14 : FROM frolvlad/alpine-glibc:alpine-3.12_glibc-2.32
 ---> 18922f3956b3
Step 7/14 : ENV PROMSQL_BIND_ADDRESS="0.0.0.0"
 ---> Using cache
 ---> 01f82e097168
Step 8/14 : ENV PROMSQL_PORT="8080"
 ---> Using cache
 ---> 4f5b8ccc842f
Step 9/14 : COPY --from=builder /go/src/app/prometheus-sql /usr/local/bin/prometheus-sql
 ---> 61ccfc50f02a
Step 10/14 : COPY docker-entrypoint.sh /usr/local/bin/
 ---> 4bda312ec678
Step 11/14 : RUN chmod +x /usr/local/bin/*
 ---> Running in 1eac7b7163cc
Removing intermediate container 1eac7b7163cc
 ---> e6529a7072c3
Step 12/14 : EXPOSE 8080
 ---> Running in abfa8b970284
Removing intermediate container abfa8b970284
 ---> 0aada5736a19
Step 13/14 : ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
 ---> Running in 6f30a9dd24d2
Removing intermediate container 6f30a9dd24d2
 ---> abab816b264c
Step 14/14 : CMD ["-service", "http://sqlagent:5000"]
 ---> Running in fe5a1777ba0b
Removing intermediate container fe5a1777ba0b
 ---> 2138250c42d3
Successfully built 2138250c42d3
Successfully tagged prometheus-sql:master

Cheers!