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

httpreplay: Get error "flag redefined: v" when trying to get new Recorder #6501

Closed
tomasbanet opened this issue Aug 10, 2022 · 6 comments
Closed
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@tomasbanet
Copy link

httpreplay version: v0.103.0

Code

_, err := httpreplay.NewRecorder("gcs-recorder-output.txt", []byte{})
if err != nil {
  return nil, err
}

Expected behavior

httpreplay.Recorder is instantiated without any errors.

Actual behavior

Got the following runtime error when trying to run the compiled binary:

panic: ./bin flag redefined: v

goroutine 1 [running]:
flag.(*FlagSet).Var(0xc00004e1e0, {0x22c1d40, 0xc0003294d8}, {0x22b2b69, 0x1}, {0x20dc402, 0x9})
	/usr/local/Cellar/go/1.18.2/libexec/src/flag/flag.go:879 +0x2f4
flag.(*FlagSet).IntVar(...)
	/usr/local/Cellar/go/1.18.2/libexec/src/flag/flag.go:658
flag.(*FlagSet).Int(0x8?, {0x22b2b69, 0x1}, 0x0, {0x20dc402, 0x9})
	/usr/local/Cellar/go/1.18.2/libexec/src/flag/flag.go:671 +0x7e
flag.Int(...)
	/usr/local/Cellar/go/1.18.2/libexec/src/flag/flag.go:678
github.com/google/martian/v3.init()
	/Users/tomasb/go/src/arista/vendor/github.com/google/martian/v3/init.go:24 +0x65

It looks like "github.com/google/martian/v3" is being imported twice. In vendor/cloud.google.com/go/httpreplay/internal/proxy/log.go and in vendor/cloud.google.com/go/httpreplay/internal/proxy/record.go. This causes the Init function from vendor/github.com/google/martian/v3/init.go to run:

var (
	level = flag.Int("v", 0, "log level")
)

// Init runs common initialization code for a martian proxy.
func Init() {
	flag.Parse()
	mlog.SetLevel(*level)
}

This seems to cause the flag parsing error.

As a work-around you can do:

// Init runs common initialization code for a martian proxy.
func Init() {
	level := flag.Int("v", 0, "log level")
	flag.Parse()
	mlog.SetLevel(*level)
}

which seems to run fine.

Go Environment

$ go version
go version go1.18.2 darwin/amd64

@codyoss
Copy link
Member

codyoss commented Aug 10, 2022

Hey, thanks for the report. Quickly reading this I would say this is an issue in martian. It looks like you found a relevant issue too. Can this be closed out. I don't believe we have a v flag at all unless I am missing something.

@codyoss codyoss added type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. labels Aug 10, 2022
@codyoss codyoss self-assigned this Aug 10, 2022
@codyoss
Copy link
Member

codyoss commented Aug 26, 2022

Closing due to lack of response.

@codyoss codyoss closed this as not planned Won't fix, can't repro, duplicate, stale Aug 26, 2022
@tomasbanet
Copy link
Author

Hi. Sorry. Looks like martian maintainers merged a fix into master 10 days ago (it's in v3.3.2). Maybe we could bump up the github.com/google/martian/v3 dependency to this version? (currently it's v3.2.1)

@codyoss
Copy link
Member

codyoss commented Aug 26, 2022

Sure, I can do that. You can always also explicitly require a higher version in your module to work around this. Just underscore import martian and depend on the latest.

@codyoss
Copy link
Member

codyoss commented Aug 26, 2022

Until we drop support for Go 1.15 we can't upgrade this dep in our code. It use a symbol net.ErrClosed from 1.16 in its latest code. We will update once we have a min support version >=1.16

@tomasbanet
Copy link
Author

tomasbanet commented Aug 26, 2022

Sure, I can do that. You can always also explicitly require a higher version in your module to work around this. Just underscore import martian and depend on the latest.

Good suggestion. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants