-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Go 1.21 compatibility: Set verbosity after flag definition #3384
Conversation
This seems to be related to a change in the klog library where the "v" flag isn't defined until after InitFlags() is called. Defer the call of setting the default verbosity until after we do that instead of during init(). Fixes startup: $ GO_FLAGS=-trimpath build/build.sh && _output/cadvisor -logtostderr >> building cadvisor go: downloading github.com/prometheus/common v0.38.0 panic: flag v set at github.com/google/cadvisor/cmd/cadvisor.go:105 before being defined goroutine 1 [running]: flag.(*FlagSet).Var(0xc00017a150, {0x1874460, 0x2213bc8}, {0x1866490, 0x1}, {0x15f0596, 0x22}) flag/flag.go:1031 +0x33a k8s.io/klog/v2.InitFlags.func1(0xc0001ab2f0?) k8s.io/klog/v2@v2.80.1/klog.go:439 +0x31 flag.(*FlagSet).VisitAll(0xc00032fa50?, 0xc0005e1c90) flag/flag.go:458 +0x42 k8s.io/klog/v2.InitFlags(0x7fbe00b2f5b8?) k8s.io/klog/v2@v2.80.1/klog.go:438 +0x45 main.main() github.com/google/cadvisor/cmd/cadvisor.go:109 +0x36 Signed-off-by: Joe Groocock <me@frebib.net>
Hi @frebib. Thanks for your PR. I'm waiting for a google member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm puzzled:
➜ cadvisor git:(master) GO_FLAGS=-trimpath build/build.sh
>> building cadvisor
go: downloading google.golang.org/api v0.126.0
go: downloading cloud.google.com/go/compute v1.23.0
go: downloading github.com/opencontainers/runc v1.1.9
go: downloading golang.org/x/net v0.10.0
go: downloading golang.org/x/crypto v0.9.0
go: downloading golang.org/x/oauth2 v0.8.0
go: downloading google.golang.org/grpc v1.57.0
go: downloading google.golang.org/protobuf v1.31.0
go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5
go: downloading google.golang.org/genproto v0.0.0-20230807174057-1744710a1577
go: downloading github.com/google/s2a-go v0.1.4
go: downloading github.com/googleapis/enterprise-certificate-proxy v0.2.3
go: downloading github.com/googleapis/gax-go/v2 v2.11.0
go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
What version of Go are you using?
Tested on:
|
@iwankgb The issue manifests when running the built binary, not the compilation.
I think I must have a newer/different version of a library that causes this to happen. Try a |
I downloaded 0.47.2 from releases page:
|
So it seems this might be related to Go 1.21. I've seen reports that building cadvisor works with 1.20, but not 1.21 (without this patch) |
This seems to be related to a change in the klog library where the "v" flag isn't defined until after InitFlags() is called. Defer the call of setting the default verbosity until after we do that instead of during init(). Fixes startup:
Possibly broken due to this? kubernetes/klog@28f7906