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
panic: flag alsologtostderr set at github.com/k3s-io/k3s/pkg/cli/cmds/log.go:78 before being defined #8293
Comments
We don't maintain or support the Alpine package. I can't reproduce this on our builds available here on GitHub - we've been producing builds with that commit that have been working fine for the last 3 years. I suspect the Alpine package is built differently somehow, and would suggest opening an issue with whoever is maintaining the Alpine package. |
The error is fairly straightforward and apparent in the upstream code as well, despite not being reproducible from the GitHub workers (maybe your Go version is out of date -- this check in the Go stdlib was only committed on 2023-03-29, see golang/go 00401835c1d). Commit 30e050a refactored the code found in this file and, among other changes, switched from the standard library's "flag" package to github.com/urfave/cli. The setupLogging function now uses flag.Set against flags which the stdlib is no longer aware of, causing it to panic. I think that this code is obsolete and can safely be removed, but I'm no expert on this codebase so I could not say for sure. In any case, you have a bug and you're going to hit it sooner or later once you upgrade your Go toolchain. |
I'm not sure what you mean by our go version being out of date; we build K3s with the exact same golang version as upstream Kubernetes uses for any given release. If the Alpine build system is not doing the same, then the build isn't guaranteed to work properly. |
once you update to go 1.21 you will see the same issue using an older version doesn't mean the issue doesn't exist. you'll just have to fix it later instead of sooner. |
If you're building any release of Kubernetes or K3s with golang 1.21 then you're not producing valid builds. You can find the correct version to be used in the upstream build dependencies yaml: This sort of attention to detail is why we generally discourage folks from from rebuilding k3s in their own build pipelines. |
You've got a bug, brother. A simple one that should be easy to fix, and a bug all the same. The code is wrong. Doesn't matter what version of Go you use, one version over the other just makes the bug more apparent. |
Yes, but its a harmless bug - I'm not particularly concerned this specific component references a CLI flag before it's been added to the flagset. I'm more concerned about Alpine distributing things claiming to be K3s that crash or otherwise misbehave because they're built with the wrong version of golang. |
It's crashing and misbehaving because there is a bug in your code. |
... that is a non-issue and only causes a crash when built with the wrong version of golang. We'll fix that when or before upstream starts using golang 1.21. |
Great. |
Hopefully this is now on the table with #9052 coming in? |
yes, @galal-hussein is aware of this issue. |
Ref: this was broken by golang/go@0040183 in go1.21
Prior to that, setting a value before the flag was defined WOULD NOT panic. The behavior may be unexpected if you're not aware of the side effects, but we were relying on it. |
Signed-off-by: Linshen Lee 1061696872@qq.com
Environmental Info:
K3s Version:
Node(s) CPU architecture, OS, and Version:
Cluster Configuration:
1 server, 0 agents, default configuration.
Describe the bug:
This change uses the standard flag package to set a couple of values. These flags were never defined, causing the standard flag package to panic.
Steps To Reproduce:
Expected behavior:
Server starts without error.
Actual behavior:
Server panics at startup.
Additional context / logs:
The text was updated successfully, but these errors were encountered: