Code Monkey home page Code Monkey logo

Comments (10)

sethvargo avatar sethvargo commented on May 28, 2024

Hi @jmorenog

Can you share more information about your setup? What libraries are you including? Can you share some code please?

from berglas.

guillaumeblaquiere avatar guillaumeblaquiere commented on May 28, 2024

Hi

I have the same problem today. I use PubSub. Without berglas my program compiled and run well, and now, I have this same error.

Here my import for PubSub (and my IDE download automatically the packages needed)

import (
	"cloud.google.com/go/pubsub"
	"context"
	"log"
	"noHrEndpoint/pkg/helpers"
	"noHrEndpoint/processMessage/models"
)

Same for Berglas (and my IDE also download automatically the packages needed)

import (
	"context"
	"github.com/GoogleCloudPlatform/berglas/pkg/berglas"
	log "github.com/sirupsen/logrus"
	"os"
	"strings"
)

When I delete manually the directory ~/go/src/github.com/GoogleCloudPlatform/berglas/vendor/golang.org/x, that works !! (Like a charm! I like it!!)

But the problem comes back when I build my container :(
I'm not Go expert for managing the dependencies exclusions (like it's possible to do with a maven exclude in Java)

from berglas.

sethvargo avatar sethvargo commented on May 28, 2024

Hi @guillaumeblaquiere @jmorenog can you please provide a small snippet of code that exhibits the panic? I just tried the following and it compiled as expected:

package main

import (
	"context"
	"log"

	"cloud.google.com/go/pubsub"
	"github.com/GoogleCloudPlatform/berglas/pkg/berglas"
)

func main() {
	ctx := context.Background()
	_, err := pubsub.NewClient(ctx, "sethvargo-default")
	if err != nil {
		log.Fatal(err)
	}

	secret, err := berglas.Access(ctx, &berglas.AccessRequest{
		Bucket: "sethvargo-secrets",
		Object: "test",
	})
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("%s", secret)
}

from berglas.

guillaumeblaquiere avatar guillaumeblaquiere commented on May 28, 2024

Hi Seth

Your snippet don't work.

  • I tried to add it to my current projet -> Don't work, same panic error
  • I started from a clean env by changing my GOPATH env var. My IDE (I use IntelliJ 2019.1 with Golang plugin) performed the 2 go get -t -> Don't work, same panic error

But I would like to provide more details on my tests. For providing you a exemple of what is going wrong, I try to build a docker container, without test step and... get, install and build work ! (yesterday I told you that my docker build failed, but... see bellow the reason)
So, then, I deployed my container to CloudRun and... Fail -> Same error.

So, YES, the compile/build step is OK. BUT, at the runtime (of test in my docker build), locally, or on Cloud Run fail with the same panic error.

To narrow your investigation, the problem is at runtime, not at compiling time.
Hope that helps !

from berglas.

sethvargo avatar sethvargo commented on May 28, 2024

Hi @guillaumeblaquiere - I'm not familiar with IntelliJ and Go, but you can copy-paste that program anywhere into a main.go file and run go run main.go. It will work as expected. Are you using Go modules?

from berglas.

guillaumeblaquiere avatar guillaumeblaquiere commented on May 28, 2024

Ok @sethvargo , let's go to command line. No IDE special stuff. Look at that

  • I change my GOPATH
  • I run your main file, it fails
  • I perform a go get then a go install
  • I run again and I have the issue
(xenial)gib@localhost:~/Downloads/base/code/go/src/goSeth$ echo $GOPATH
/home/gib/Downloads/base/code/go
(xenial)gib@localhost:~/Downloads/base/code/go/src/goSeth$ go run main.go
main.go:7:2: cannot find package "cloud.google.com/go/pubsub" in any of:
/usr/local/go/src/cloud.google.com/go/pubsub (from $GOROOT)
/home/gib/Downloads/base/code/go/src/cloud.google.com/go/pubsub (from $GOPATH)
main.go:8:2: cannot find package "github.com/GoogleCloudPlatform/berglas/pkg/berglas" in any of:
/usr/local/go/src/github.com/GoogleCloudPlatform/berglas/pkg/berglas (from $GOROOT)
/home/gib/Downloads/base/code/go/src/github.com/GoogleCloudPlatform/berglas/pkg/berglas (from $GOPATH)
(xenial)gib@localhost:~/Downloads/base/code/go/src/goSeth$ go get ./...
(xenial)gib@localhost:~/Downloads/base/code/go/src/goSeth$ go install ./...
(xenial)gib@localhost:~/Downloads/base/code/go/src/goSeth$ go run main.go
panic: /debug/requests is already registered. You may have two independent copies of golang.org/x/net/trace in your binary, trying to maintain separate state. This may involve a vendored copy of golang.org/x/net/trace.

goroutine 1 [running]:
github.com/GoogleCloudPlatform/berglas/vendor/golang.org/x/net/trace.init.0()
/home/gib/Downloads/base/code/go/src/github.com/GoogleCloudPlatform/berglas/vendor/golang.org/x/net/trace/trace.go:123 +0x1cf
exit status 2
(xenial)gib@localhost:~/Downloads/base/code/go/src/goSeth$

I don't use Go Modules (I don't know what it is yet, I'm a Go dev since 2 weeks! Not yet a gopher!)

from berglas.

sethvargo avatar sethvargo commented on May 28, 2024

Can you run export GO111MODULE=on and try again?

from berglas.

guillaumeblaquiere avatar guillaumeblaquiere commented on May 28, 2024

Hi @sethvargo. It's working !! See bellow my logs. I have a 403 error, but I don't care, no the panic error.
So, I think that this module activation has to be mention in the readme file.
Finally, I will be happy to learn and understand more about module and dependencies version. If you have great websites to recommend me, I would like to know more about that ;)
(EDITED : Finally I activated the module support on IntelliJ and a go.mod file has been created with version and so on. I have to deep dive to understand the indirect dependencies, but it's a starting point!)

Thanks for you help !

First run

(xenial)gib@localhost:~/Downloads/base/code/go/src/goSeth$ export GO111MODULE=on
(xenial)gib@localhost:~/Downloads/base/code/go/src/goSeth$ go run main.go
go: finding github.com/GoogleCloudPlatform/berglas/pkg/berglas latest
go: finding cloud.google.com/go/pubsub latest
go: finding github.com/GoogleCloudPlatform/berglas/pkg latest
go: finding github.com/GoogleCloudPlatform/berglas v0.1.1
go: downloading github.com/GoogleCloudPlatform/berglas v0.1.1
go: extracting github.com/GoogleCloudPlatform/berglas v0.1.1
go: finding cloud.google.com/go v0.39.0
go: downloading cloud.google.com/go v0.39.0
go: extracting cloud.google.com/go v0.39.0
go: finding github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57
go: finding github.com/spf13/cobra v0.0.3
go: finding github.com/golang/mock v1.2.0
go: finding golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f
go: finding golang.org/x/time v0.0.0-20181108054448-85acf8d2951c
go: finding golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6
go: finding golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421
go: finding golang.org/x/exp v0.0.0-20190121172915-509febef88a4
go: finding google.golang.org/api v0.5.0
go: finding honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a
go: finding golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a
go: finding cloud.google.com/go v0.37.4
go: finding github.com/google/martian v2.1.0+incompatible
go: finding github.com/golang/protobuf v1.2.0
go: finding golang.org/x/tools v0.0.0-20190312170243-e65039ee4138
go: finding golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
go: finding google.golang.org/api v0.3.2
go: finding golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e
go: finding google.golang.org/genproto v0.0.0-20190508193815-b515fa19cec8
go: finding github.com/pkg/errors v0.8.1
go: finding github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024
go: finding github.com/golang/protobuf v1.3.1
go: finding cloud.google.com/go v0.34.0
go: finding google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107
go: finding golang.org/x/net v0.0.0-20190311183353-d8887717615a
go: finding golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2
go: finding github.com/googleapis/gax-go/v2 v2.0.4
go: finding google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7
go: finding golang.org/x/net v0.0.0-20190213061140-3a22650c66bd
go: finding go.opencensus.io v0.20.1
go: finding go.opencensus.io v0.21.0
go: finding google.golang.org/grpc v1.19.0
go: finding golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961
go: finding google.golang.org/grpc v1.20.0
go: finding github.com/google/go-cmp v0.2.0
go: finding google.golang.org/api v0.3.1
go: finding golang.org/x/tools v0.0.0-20190226205152-f727befe758c
go: finding github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829
go: finding google.golang.org/appengine v1.1.0
go: finding google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8
go: finding honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099
go: finding google.golang.org/appengine v1.4.0
go: finding github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
go: finding github.com/prometheus/common v0.2.0
go: finding golang.org/x/sys v0.0.0-20180830151530-49385e6e1522
go: finding github.com/openzipkin/zipkin-go v0.1.6
go: finding github.com/envoyproxy/go-control-plane v0.6.9
go: finding golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b
go: finding github.com/hashicorp/golang-lru v0.5.0
go: finding golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3
go: finding golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
go: finding github.com/Shopify/toxiproxy v2.1.4+incompatible
go: finding golang.org/x/text v0.3.0
go: finding google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19
go: finding github.com/gogo/protobuf v1.2.0
go: finding golang.org/x/net v0.0.0-20180724234803-3673e40ba225
go: finding github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a
go: finding golang.org/x/tools v0.0.0-20190114222345-bf090417da8b
go: finding golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5
go: finding github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d
go: finding github.com/pkg/errors v0.8.0
go: finding github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b
go: finding github.com/gogo/protobuf v1.1.1
go: finding cloud.google.com/go v0.26.0
go: finding golang.org/x/sync v0.0.0-20181108010431-42b317875d0f
go: finding github.com/davecgh/go-spew v1.1.1
go: finding golang.org/x/net v0.0.0-20180826012351-8a410e7b638d
go: finding github.com/matttproud/golang_protobuf_extensions v1.0.1
go: finding github.com/go-logfmt/logfmt v0.3.0
go: finding github.com/gorilla/context v1.1.1
go: finding github.com/apache/thrift v0.12.0
go: finding github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1
go: finding github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf
go: finding github.com/client9/misspell v0.3.4
go: finding github.com/Shopify/sarama v1.19.0
go: finding golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
go: finding github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f
go: finding github.com/go-stack/stack v1.8.0
go: finding github.com/onsi/ginkgo v1.7.0
go: finding google.golang.org/grpc v1.17.0
go: finding github.com/lyft/protoc-gen-validate v0.0.13
go: finding github.com/onsi/gomega v1.4.3
go: finding github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223
go: finding github.com/julienschmidt/httprouter v1.2.0
go: finding github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21
go: finding golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3
go: finding github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c
go: finding github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515
go: finding github.com/GoogleCloudPlatform/berglas/examples/cloudrun/go v0.0.0-20190424021200-7aa8a2613e06
go: finding golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52
go: finding github.com/pierrec/lz4 v2.0.5+incompatible
go: finding github.com/go-kit/kit v0.8.0
go: finding golang.org/x/tools v0.0.0-20190311212946-11955173bddd
go: finding github.com/sirupsen/logrus v1.2.0
go: finding github.com/eapache/queue v1.1.0
go: finding github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc
go: finding github.com/prometheus/client_golang v0.9.1
go: finding github.com/kisielk/gotool v1.0.0
go: finding github.com/stretchr/objx v0.1.1
go: finding golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33
go: finding golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e
go: finding golang.org/x/net v0.0.0-20180906233101-161cd47e91fd
go: finding github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db
go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: finding github.com/stretchr/testify v1.2.2
go: finding github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973
go: finding github.com/BurntSushi/toml v0.3.1
go: finding gopkg.in/fsnotify.v1 v1.4.7
go: finding golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3
go: finding github.com/GoogleCloudPlatform/berglas v0.0.0-20190418221342-65552e561ec3
go: finding github.com/fsnotify/fsnotify v1.4.7
go: finding github.com/gogo/googleapis v1.1.0
go: finding honnef.co/go/tools v0.0.0-20180728063816-88497007e858
go: finding golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db
go: finding golang.org/x/net v0.0.0-20190415214537-1da14a5a36f2
go: finding golang.org/x/sys v0.0.0-20190418153312-f0ce4c0180be
go: finding github.com/eapache/go-resiliency v1.1.0
go: finding github.com/onsi/ginkgo v1.6.0
go: finding github.com/kr/pretty v0.1.0
go: finding gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: finding gopkg.in/yaml.v2 v2.2.1
go: finding github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910
go: finding google.golang.org/appengine v1.5.0
go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: finding github.com/konsorten/go-windows-terminal-sequences v1.0.1
go: finding go.opencensus.io v0.20.2
go: finding github.com/inconshreveable/mousetrap v1.0.0
go: finding golang.org/x/crypto v0.0.0-20180904163835-0709b304e793
go: finding github.com/spf13/pflag v1.0.3
go: finding github.com/hashicorp/golang-lru v0.5.1
go: finding github.com/hpcloud/tail v1.0.0
go: finding github.com/golang/mock v1.1.1
go: finding golang.org/x/net v0.0.0-20181114220301-adae6a3d119a
go: finding gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
go: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
go: finding github.com/gorilla/mux v1.6.2
go: finding github.com/kr/text v0.1.0
go: finding golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e
go: finding gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding github.com/kr/pty v1.1.1
go: downloading google.golang.org/grpc v1.20.0
go: downloading go.opencensus.io v0.21.0
go: downloading google.golang.org/genproto v0.0.0-20190508193815-b515fa19cec8
go: downloading golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6
go: downloading google.golang.org/api v0.5.0
go: downloading github.com/googleapis/gax-go/v2 v2.0.4
go: extracting golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6
go: extracting github.com/googleapis/gax-go/v2 v2.0.4
go: downloading github.com/golang/protobuf v1.3.1
go: extracting go.opencensus.io v0.21.0
go: extracting github.com/golang/protobuf v1.3.1
go: extracting google.golang.org/grpc v1.20.0
go: extracting google.golang.org/genproto v0.0.0-20190508193815-b515fa19cec8
go: downloading golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a
go: downloading github.com/pkg/errors v0.8.1
go: extracting github.com/pkg/errors v0.8.1
go: downloading golang.org/x/net v0.0.0-20190415214537-1da14a5a36f2
go: extracting golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a
go: extracting google.golang.org/api v0.5.0
go: extracting golang.org/x/net v0.0.0-20190415214537-1da14a5a36f2
go: downloading golang.org/x/sys v0.0.0-20190418153312-f0ce4c0180be
go: downloading github.com/hashicorp/golang-lru v0.5.1
go: downloading golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db
go: extracting github.com/hashicorp/golang-lru v0.5.1
go: extracting golang.org/x/sys v0.0.0-20190418153312-f0ce4c0180be
go: extracting golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db
2019/05/16 10:07:28 failed to read secret metadata: googleapi: Error 403: [email protected] does not have storage.objects.get access to sethvargo-secrets/test., forbidden
exit status 1
(xenial)gib@localhost:~/Downloads/base/code/go/src/goSeth$

Next run, quicker launch and shorter log line!

(xenial)gib@localhost:~/Downloads/base/code/go/src/goSeth$ go run main.go
go: finding github.com/GoogleCloudPlatform/berglas/pkg/berglas latest
go: finding github.com/GoogleCloudPlatform/berglas/pkg latest
go: finding cloud.google.com/go/pubsub latest
2019/05/16 10:08:52 failed to read secret metadata: googleapi: Error 403: [email protected] does not have storage.objects.get access to sethvargo-secrets/test., forbidden
exit status 1

from berglas.

sethvargo avatar sethvargo commented on May 28, 2024

Hi @guillaumeblaquiere it's expected you'd get an error because you don't have access to my secrets. I'm glad that you're not getting an error anymore. You can learn more about go modules here.

from berglas.

guillaumeblaquiere avatar guillaumeblaquiere commented on May 28, 2024

@sethvargo, it's perfect ! Modules were one of missing pieces to build modular app with package dependencies, with specific version,...
Maybe, this need to be improved in next version of Go, but this starting point is great, I even can define project submodule by using "replace" keyword. Excellent !!
Thanks so much!

from berglas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.