Repository navigation
Conversation
|
|
|
Welcome @rawmeat21! |
|
Hi @rawmeat21. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rawmeat21 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Can one of the admins verify this patch? |
| } | ||
|
|
||
| // used in update_kubeadm_constants.go | ||
| flag.String("kubernetes-version", "latest", "kubernetes-version") |
There was a problem hiding this comment.
This flag is used in update_kubeadm_constants.go - why is it defined here? Move it to the program that uses it.
There was a problem hiding this comment.
Hi, I'm haven't looked much into why it's defined there, this line was already present in the previous init() (which I renamed to Init()) function so I didn't give it much thought. Also, I tried finding an update_kubeadm_constants.go file but didn't really find one with that name. There is a kubeadm_constants.go file in hack/update/kubeadm_constants though. Are these supposed to be the same file?
| } | ||
| if err := flag.Set("alsologtostderr", "true"); err != nil { | ||
| klog.Warningf("Unable to set flag value for alsologtostderr: %v", err) | ||
| } |
There was a problem hiding this comment.
Why do we need klog.InitFlags? Do we use klog in the update programs? We should switch to more ergonomic logger lize zap.
But before we switch, we need to understand if this is needed for all update programs, or only for some. If this is common, it makes sense to keep InitFlags() helper that all programs will use. If only some programs need this, we should drop this and initialize what we need in each program.
There was a problem hiding this comment.
Hi, new to contributing here. klog.InitFlags was actually part of the existing code before I made the change. I did check though, seems like only a few files in hack/update don't use klogs, these files are: update_all/update_all.go, dockerhub.go, get_version/get_version.go, image.go and github.go. Rest of the files seem to use klogs.
There was a problem hiding this comment.
ok, so this is common setup that will be good to do in the update library. Just ned to make the function more clear (e.g. InitFlags() or AddCommonFlags())
There was a problem hiding this comment.
Alright, renamed update.Init() to update.InitFlags()
Fixes #24034
hack/update/update.gocalledflag.Parse()frominit(), which ran before the generated test'smain()calledtesting.Init()to register the-test.*flags. So,flag.Parse()would fail as it would see flags which weren't registered yet.Changed
hack/update/update.go'sinit()with anInit()with the same body:init()function is not present, so it won't run whenk8s.io/minikube/hack/updateis imported.main()function would not callupdate.Init(), so tests can be added now.For every package that imports
k8s.io/minikube/hack/update, I added anupdate.Init()line at the top of theirmain()function. So, the previousinit()'s code still runs, and the functionality is preserved.To test this, I created a
docker_version_test.go(this file is not included in the fix) inhack/update/docker_versionand ran the following commands:Before, this command would fail in the previous version:
The
make update-*targets should also behave the same, for example, I ran the following command on my machine:This gave the same output before and after the changes were made.
kubernetes-versionflag also works as before.go fmtandgo vetare all clean.go build ./update/...succeeds without errors.I would also add that this fix requires every package which imports
k8s.io/minikube/hack/updateto add aupdate.Init()line at the top of theirmainfunction to initialisek8s.io/minikube/hack/updatefrom now on. I hope that's okay, I'm open to making any improvements on this approach.