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
logs: remove deprecated klog flags #112120
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
Copyright 2022 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package klogflags | ||
|
||
import ( | ||
"flag" | ||
|
||
"k8s.io/klog/v2" | ||
) | ||
|
||
// Init is a replacement for klog.InitFlags which only adds those flags | ||
// that are still supported for Kubernetes components (i.e. -v and -vmodule). | ||
// See | ||
// https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components. | ||
func Init(fs *flag.FlagSet) { | ||
var allFlags flag.FlagSet | ||
klog.InitFlags(&allFlags) | ||
if fs == nil { | ||
fs = flag.CommandLine | ||
} | ||
allFlags.VisitAll(func(f *flag.Flag) { | ||
switch f.Name { | ||
case "v", "vmodule": | ||
fs.Var(f.Value, f.Name, f.Usage) | ||
} | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ TIMEOUT=${TIMEOUT:-"45m"} | |
mkdir -p "${ARTIFACTS}" | ||
|
||
go run test/e2e_node/runner/remote/run_remote.go --test-suite=conformance \ | ||
--logtostderr --vmodule=*=4 --ssh-env="gce" --ssh-user="$GCE_USER" \ | ||
--vmodule=*=4 --ssh-env="gce" --ssh-user="$GCE_USER" \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the change in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. None. Logging to stderr has been the default for several years now, so using this parameter didn't change anything. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. Thanks for clarifying. |
||
--zone="$GCE_ZONE" --project="$GCE_PROJECT" --hosts="$GCE_HOSTS" \ | ||
--images="$GCE_IMAGES" --image-project="$GCE_IMAGE_PROJECT" \ | ||
--image-config-file="$GCE_IMAGE_CONFIG_PATH" --cleanup="$CLEANUP" \ | ||
|
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 unclear why this moved to a different package, personally.
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.
It's used in
k8s.io/component-base/logs/api/v1
to access the klog settings and determine which logging flags exist, which in turn is used to warn about those that only have an effect in the text format (used to more, now it's only-vmodule
which isn't supported by zapr).If it was not moved into a separate leaf package, there would be a circular dependency. Before,
api/v1
directly calledklog.InitFlags
, but that's not correct anymore because only a subset of those flags are active.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.
Perhaps I also need to explain why klogflags is needed and why it is under component-base: