Skip to content

Commit e250f13

Browse files
committed
UPSTREAM: <DEBUG>: Revert "Merge pull request kubernetes#112120 from pohly/klog-flag-removal"
This reverts commit 6dbec8e, reversing changes made to 17c5066.
1 parent c6fedc2 commit e250f13

File tree

16 files changed

+77
-72
lines changed

16 files changed

+77
-72
lines changed

hack/jenkins/benchmark-dockerized.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ cd "${GOPATH}/src/k8s.io/kubernetes"
6666
./hack/install-etcd.sh
6767

6868
# Run the benchmark tests and pretty-print the results into a separate file.
69-
# Log output of the tests go to stderr.
70-
make test-integration WHAT="$*" KUBE_TEST_ARGS="-run='XXX' -bench=${TEST_PREFIX:-.} -benchtime=${BENCHTIME:-1s} -benchmem -data-items-dir=${ARTIFACTS}" \
69+
make test-integration WHAT="$*" KUBE_TEST_ARGS="-run='XXX' -bench=${TEST_PREFIX:-.} -benchtime=${BENCHTIME:-1s} -benchmem -alsologtostderr=false -logtostderr=false -data-items-dir=${ARTIFACTS}" \
7170
| (go run test/integration/benchmark/extractlog/main.go) \
7271
| tee \
7372
>(prettybench -no-passthrough > "${ARTIFACTS}/BenchmarkResults.txt") \

hack/make-rules/test-e2e-node.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ if [ "${remote}" = true ] && [ "${remote_mode}" = gce ] ; then
162162
echo "Kubelet Config File: ${kubelet_config_file}"
163163

164164
# Invoke the runner
165-
go run test/e2e_node/runner/remote/run_remote.go --vmodule=*=4 --ssh-env="gce" \
165+
go run test/e2e_node/runner/remote/run_remote.go --logtostderr --vmodule=*=4 --ssh-env="gce" \
166166
--zone="${zone}" --project="${project}" --gubernator="${gubernator}" \
167167
--hosts="${hosts}" --images="${images}" --cleanup="${cleanup}" \
168168
--results-dir="${artifacts}" --ginkgo-flags="${ginkgoflags}" --runtime-config="${runtime_config}" \
@@ -189,7 +189,7 @@ elif [ "${remote}" = true ] && [ "${remote_mode}" = ssh ] ; then
189189
test_args='--kubelet-flags="--cluster-domain='${KUBE_DNS_DOMAIN:-cluster.local}'" '${test_args}
190190

191191
# Invoke the runner
192-
go run test/e2e_node/runner/remote/run_remote.go --mode="ssh" --vmodule=*=4 \
192+
go run test/e2e_node/runner/remote/run_remote.go --mode="ssh" --logtostderr --vmodule=*=4 \
193193
--hosts="${hosts}" --results-dir="${artifacts}" --ginkgo-flags="${ginkgoflags}" \
194194
--test_args="${test_args}" --system-spec-name="${system_spec_name}" \
195195
--runtime-config="${runtime_config}" \
@@ -222,7 +222,7 @@ else
222222
go run test/e2e_node/runner/local/run_local.go \
223223
--system-spec-name="${system_spec_name}" --extra-envs="${extra_envs}" \
224224
--ginkgo-flags="${ginkgoflags}" \
225-
--test-flags="--v 4 --report-dir=${artifacts} --node-name $(hostname) ${test_args}" \
225+
--test-flags="--alsologtostderr --v 4 --report-dir=${artifacts} --node-name $(hostname) ${test_args}" \
226226
--runtime-config="${runtime_config}" \
227227
--kubelet-config-file="${kubelet_config_file}" \
228228
--build-dependencies=true 2>&1 | tee -i "${artifacts}/build-log.txt"

hack/make-rules/test-integration.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ runTests() {
7878
make -C "${KUBE_ROOT}" test \
7979
WHAT="${WHAT:-$(kube::test::find_integration_test_dirs | paste -sd' ' -)}" \
8080
GOFLAGS="${GOFLAGS:-}" \
81-
KUBE_TEST_ARGS="${SHORT:--short=true} --vmodule=${KUBE_TEST_VMODULE} ${KUBE_TEST_ARGS:-}" \
81+
KUBE_TEST_ARGS="--alsologtostderr=true ${SHORT:--short=true} --vmodule=${KUBE_TEST_VMODULE} ${KUBE_TEST_ARGS:-}" \
8282
KUBE_TIMEOUT="${KUBE_TIMEOUT}" \
8383
KUBE_RACE=""
8484

hack/update-openapi-spec.sh

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ kube::log::status "Starting kube-apiserver"
8484
--service-account-lookup="${SERVICE_ACCOUNT_LOOKUP}" \
8585
--service-account-issuer="https://kubernetes.default.svc" \
8686
--service-account-signing-key-file="${SERVICE_ACCOUNT_KEY}" \
87+
--logtostderr \
8788
--v=2 \
8889
--service-cluster-ip-range="10.0.0.0/24" >"${API_LOGFILE}" 2>&1 &
8990
APISERVER_PID=$!

staging/src/k8s.io/component-base/cli/globalflag/globalflags_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func TestAddGlobalFlags(t *testing.T) {
6262
}{
6363
{
6464
// Happy case
65-
expectedFlag: []string{"help", "log-flush-frequency", "v", "vmodule"},
65+
expectedFlag: []string{"add-dir-header", "alsologtostderr", "help", "log-backtrace-at", "log-dir", "log-file", "log-file-max-size", "log-flush-frequency", "logtostderr", "one-output", "skip-headers", "skip-log-headers", "stderrthreshold", "v", "vmodule"},
6666
matchExpected: false,
6767
},
6868
{

staging/src/k8s.io/component-base/logs/api/v1/options.go

+20-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"flag"
2121
"fmt"
2222
"math"
23+
"sort"
2324
"strings"
2425
"time"
2526

@@ -31,7 +32,6 @@ import (
3132
"k8s.io/apimachinery/pkg/util/validation/field"
3233
cliflag "k8s.io/component-base/cli/flag"
3334
"k8s.io/component-base/featuregate"
34-
"k8s.io/component-base/logs/klogflags"
3535
)
3636

3737
const (
@@ -183,8 +183,12 @@ func apply(c *LoggingConfiguration, featureGate featuregate.FeatureGate) error {
183183

184184
// AddFlags adds command line flags for the configuration.
185185
func AddFlags(c *LoggingConfiguration, fs *pflag.FlagSet) {
186+
// The help text is generated assuming that flags will eventually use
187+
// hyphens, even if currently no normalization function is set for the
188+
// flag set yet.
189+
unsupportedFlags := strings.Join(unsupportedLoggingFlagNames(cliflag.WordSepNormalizeFunc), ", ")
186190
formats := logRegistry.list()
187-
fs.StringVar(&c.Format, "logging-format", c.Format, fmt.Sprintf("Sets the log format. Permitted formats: %s.", formats))
191+
fs.StringVar(&c.Format, "logging-format", c.Format, fmt.Sprintf("Sets the log format. Permitted formats: %s.\nNon-default formats don't honor these flags: %s.\nNon-default choices are currently alpha and subject to change without warning.", formats, unsupportedFlags))
188192
// No new log formats should be added after generation is of flag options
189193
logRegistry.freeze()
190194

@@ -232,13 +236,14 @@ var loggingFlags pflag.FlagSet
232236

233237
func init() {
234238
var fs flag.FlagSet
235-
klogflags.Init(&fs)
239+
klog.InitFlags(&fs)
236240
loggingFlags.AddGoFlagSet(&fs)
237241
}
238242

239243
// List of logs (k8s.io/klog + k8s.io/component-base/logs) flags supported by all logging formats
240244
var supportedLogsFlags = map[string]struct{}{
241245
"v": {},
246+
// TODO: support vmodule after 1.19 Alpha
242247
}
243248

244249
// unsupportedLoggingFlags lists unsupported logging flags. The normalize
@@ -263,3 +268,15 @@ func unsupportedLoggingFlags(normalizeFunc func(f *pflag.FlagSet, name string) p
263268
})
264269
return allFlags
265270
}
271+
272+
// unsupportedLoggingFlagNames lists unsupported logging flags by name, with
273+
// optional normalization and sorted.
274+
func unsupportedLoggingFlagNames(normalizeFunc func(f *pflag.FlagSet, name string) pflag.NormalizedName) []string {
275+
unsupportedFlags := unsupportedLoggingFlags(normalizeFunc)
276+
names := make([]string, 0, len(unsupportedFlags))
277+
for _, f := range unsupportedFlags {
278+
names = append(names, "--"+f.Name)
279+
}
280+
sort.Strings(names)
281+
return names
282+
}

staging/src/k8s.io/component-base/logs/api/v1/options_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ func TestFlags(t *testing.T) {
3939
fs.SetOutput(&output)
4040
fs.PrintDefaults()
4141
want := ` --log-flush-frequency duration Maximum number of seconds between log flushes (default 5s)
42-
--logging-format string Sets the log format. Permitted formats: "text". (default "text")
42+
--logging-format string Sets the log format. Permitted formats: "text".
43+
Non-default formats don't honor these flags: --add-dir-header, --alsologtostderr, --log-backtrace-at, --log-dir, --log-file, --log-file-max-size, --logtostderr, --one-output, --skip-headers, --skip-log-headers, --stderrthreshold, --vmodule.
44+
Non-default choices are currently alpha and subject to change without warning. (default "text")
4345
-v, --v Level number for the log level verbosity
4446
--vmodule pattern=N,... comma-separated list of pattern=N settings for file-filtered logging (only works for text log format)
4547
`

staging/src/k8s.io/component-base/logs/klogflags/klogflags.go

-41
This file was deleted.

staging/src/k8s.io/component-base/logs/logs.go

+37-11
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,16 @@ import (
2727

2828
"github.com/spf13/pflag"
2929
logsapi "k8s.io/component-base/logs/api/v1"
30-
"k8s.io/component-base/logs/klogflags"
3130
"k8s.io/klog/v2"
3231
)
3332

34-
const vmoduleUsage = " (only works for the default text log format)"
33+
const deprecated = "will be removed in a future release, see https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/2845-deprecate-klog-specific-flags-in-k8s-components"
34+
35+
// TODO (https://github.com/kubernetes/kubernetes/issues/105310): once klog
36+
// flags are removed, stop warning about "Non-default formats don't honor these
37+
// flags" in config.go and instead add this remark here.
38+
//
39+
// const vmoduleUsage = " (only works for the default text log format)"
3540

3641
var (
3742
packageFlags = flag.NewFlagSet("logging", flag.ContinueOnError)
@@ -42,7 +47,7 @@ var (
4247
)
4348

4449
func init() {
45-
klogflags.Init(packageFlags)
50+
klog.InitFlags(packageFlags)
4651
packageFlags.DurationVar(&logFlushFreq, logsapi.LogFlushFreqFlagName, logsapi.LogFlushFreqDefault, "Maximum number of seconds between log flushes")
4752
}
4853

@@ -76,29 +81,42 @@ var NewOptions = logsapi.NewLoggingConfiguration
7681
//
7782
// May be called more than once.
7883
func AddFlags(fs *pflag.FlagSet, opts ...Option) {
84+
// Determine whether the flags are already present by looking up one
85+
// which always should exist.
86+
if fs.Lookup("logtostderr") != nil {
87+
return
88+
}
89+
7990
o := addFlagsOptions{}
8091
for _, opt := range opts {
8192
opt(&o)
8293
}
8394

84-
// Add all supported flags.
95+
// Add flags with pflag deprecation remark for some klog flags.
8596
packageFlags.VisitAll(func(f *flag.Flag) {
8697
pf := pflag.PFlagFromGoFlag(f)
8798
switch f.Name {
88-
case "v", logsapi.LogFlushFreqFlagName:
99+
case "v":
100+
// unchanged, potentially skip it
101+
if o.skipLoggingConfigurationFlags {
102+
return
103+
}
104+
case logsapi.LogFlushFreqFlagName:
89105
// unchanged, potentially skip it
90106
if o.skipLoggingConfigurationFlags {
91107
return
92108
}
93109
case "vmodule":
110+
// TODO: see above
111+
// pf.Usage += vmoduleUsage
94112
if o.skipLoggingConfigurationFlags {
95113
return
96114
}
97-
pf.Usage += vmoduleUsage
98-
}
99-
if fs.Lookup(pf.Name) == nil {
100-
fs.AddFlag(pf)
115+
default:
116+
// deprecated, but not hidden
117+
pf.Deprecated = deprecated
101118
}
119+
fs.AddFlag(pf)
102120
})
103121
}
104122

@@ -119,16 +137,24 @@ func AddGoFlags(fs *flag.FlagSet, opts ...Option) {
119137
packageFlags.VisitAll(func(f *flag.Flag) {
120138
usage := f.Usage
121139
switch f.Name {
122-
case "v", logsapi.LogFlushFreqFlagName:
140+
case "v":
141+
// unchanged
142+
if o.skipLoggingConfigurationFlags {
143+
return
144+
}
145+
case logsapi.LogFlushFreqFlagName:
123146
// unchanged
124147
if o.skipLoggingConfigurationFlags {
125148
return
126149
}
127150
case "vmodule":
151+
// TODO: see above
152+
// usage += vmoduleUsage
128153
if o.skipLoggingConfigurationFlags {
129154
return
130155
}
131-
usage += vmoduleUsage
156+
default:
157+
usage += " (DEPRECATED: " + deprecated + ")"
132158
}
133159
fs.Var(f.Value, f.Name, usage)
134160
})

test/e2e_node/conformance/run_test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ start_kubelet --kubeconfig "${KUBELET_KUBECONFIG}" \
201201
--system-cgroups=/system \
202202
--cgroup-root=/ \
203203
--v=$log_level \
204+
--logtostderr
204205

205206
wait_kubelet
206207

test/e2e_node/jenkins/conformance/conformance-jenkins.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ TIMEOUT=${TIMEOUT:-"45m"}
3131
mkdir -p "${ARTIFACTS}"
3232

3333
go run test/e2e_node/runner/remote/run_remote.go --test-suite=conformance \
34-
--vmodule=*=4 --ssh-env="gce" --ssh-user="$GCE_USER" \
34+
--logtostderr --vmodule=*=4 --ssh-env="gce" --ssh-user="$GCE_USER" \
3535
--zone="$GCE_ZONE" --project="$GCE_PROJECT" --hosts="$GCE_HOSTS" \
3636
--images="$GCE_IMAGES" --image-project="$GCE_IMAGE_PROJECT" \
3737
--image-config-file="$GCE_IMAGE_CONFIG_PATH" --cleanup="$CLEANUP" \

test/e2e_node/remote/node_conformance.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func launchKubelet(host, workspace, results, testArgs, bearerToken string) error
181181
return fmt.Errorf("failed to create kubelet pod manifest path %q: error - %v output - %q",
182182
podManifestPath, err, output)
183183
}
184-
startKubeletCmd := fmt.Sprintf("./%s --run-kubelet-mode --node-name=%s"+
184+
startKubeletCmd := fmt.Sprintf("./%s --run-kubelet-mode --logtostderr --node-name=%s"+
185185
" --bearer-token=%s"+
186186
" --report-dir=%s %s --kubelet-flags=--pod-manifest-path=%s > %s 2>&1",
187187
conformanceTestBinary, host, bearerToken, results, testArgs, podManifestPath, filepath.Join(results, kubeletLauncherLog))

test/e2e_node/remote/node_e2e.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func (n *NodeE2ERemote) RunTest(host, workspace, results, imageDesc, junitFilePr
200200
klog.V(2).Infof("Starting tests on %q", host)
201201
cmd := getSSHCommand(" && ",
202202
fmt.Sprintf("cd %s", workspace),
203-
fmt.Sprintf("timeout -k 30s %fs ./ginkgo %s ./e2e_node.test -- --system-spec-name=%s --system-spec-file=%s --extra-envs=%s --runtime-config=%s --v 4 --node-name=%s --report-dir=%s --report-prefix=%s --image-description=\"%s\" %s",
203+
fmt.Sprintf("timeout -k 30s %fs ./ginkgo %s ./e2e_node.test -- --system-spec-name=%s --system-spec-file=%s --extra-envs=%s --runtime-config=%s --logtostderr --v 4 --node-name=%s --report-dir=%s --report-prefix=%s --image-description=\"%s\" %s",
204204
timeout.Seconds(), ginkgoArgs, systemSpecName, systemSpecFile, extraEnvs, runtimeConfig, host, results, junitFilePrefix, imageDesc, testArgs),
205205
)
206206
return SSH(host, "sh", "-c", cmd)

test/e2e_node/runner/remote/run_remote.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ limitations under the License.
1515
*/
1616

1717
// To run the node e2e tests remotely against one or more hosts on gce:
18-
// $ go run run_remote.go --v 2 --ssh-env gce --hosts <comma separated hosts>
18+
// $ go run run_remote.go --logtostderr --v 2 --ssh-env gce --hosts <comma separated hosts>
1919
// To run the node e2e tests remotely against one or more images on gce and provision them:
20-
// $ go run run_remote.go --v 2 --project <project> --zone <zone> --ssh-env gce --images <comma separated images>
20+
// $ go run run_remote.go --logtostderr --v 2 --project <project> --zone <zone> --ssh-env gce --images <comma separated images>
2121
package main
2222

2323
import (

test/e2e_node/services/kubelet.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func (e *E2EServices) startKubelet(featureGates map[string]bool) (*server, error
253253
cmdArgs = append(cmdArgs,
254254
"--kubeconfig", kubeconfigPath,
255255
"--root-dir", KubeletRootDirectory,
256-
"--v", LogVerbosityLevel,
256+
"--v", LogVerbosityLevel, "--logtostderr",
257257
)
258258

259259
// Apply test framework feature gates by default. This could also be overridden

test/integration/scheduler_perf/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ How To Run
3232

3333
```shell
3434
# In Kubernetes root path
35-
make test-integration WHAT=./test/integration/scheduler_perf ETCD_LOGLEVEL=warn KUBE_TEST_VMODULE="''" KUBE_TEST_ARGS="-run=^$$ -benchtime=1ns -bench=BenchmarkPerfScheduling"
35+
make test-integration WHAT=./test/integration/scheduler_perf ETCD_LOGLEVEL=warn KUBE_TEST_VMODULE="''" KUBE_TEST_ARGS="-alsologtostderr=false -logtostderr=false -run=^$$ -benchtime=1ns -bench=BenchmarkPerfScheduling"
3636
```
3737

3838
The benchmark suite runs all the tests specified under config/performance-config.yaml.
@@ -47,14 +47,14 @@ Otherwise, the golang benchmark framework will try to run a test more than once
4747

4848
```shell
4949
# In Kubernetes root path
50-
make test-integration WHAT=./test/integration/scheduler_perf ETCD_LOGLEVEL=warn KUBE_TEST_VMODULE="''" KUBE_TEST_ARGS="-run=^$$ -benchtime=1ns -bench=BenchmarkPerfScheduling/SchedulingBasic/5000Nodes/5000InitPods/1000PodsToSchedule"
50+
make test-integration WHAT=./test/integration/scheduler_perf ETCD_LOGLEVEL=warn KUBE_TEST_VMODULE="''" KUBE_TEST_ARGS="-alsologtostderr=false -logtostderr=false -run=^$$ -benchtime=1ns -bench=BenchmarkPerfScheduling/SchedulingBasic/5000Nodes/5000InitPods/1000PodsToSchedule"
5151
```
5252

5353
To produce a cpu profile:
5454

5555
```shell
5656
# In Kubernetes root path
57-
make test-integration WHAT=./test/integration/scheduler_perf KUBE_TIMEOUT="-timeout=3600s" ETCD_LOGLEVEL=warn KUBE_TEST_VMODULE="''" KUBE_TEST_ARGS="-run=^$$ -benchtime=1ns -bench=BenchmarkPerfScheduling -cpuprofile ~/cpu-profile.out"
57+
make test-integration WHAT=./test/integration/scheduler_perf KUBE_TIMEOUT="-timeout=3600s" ETCD_LOGLEVEL=warn KUBE_TEST_VMODULE="''" KUBE_TEST_ARGS="-alsologtostderr=false -logtostderr=false -run=^$$ -benchtime=1ns -bench=BenchmarkPerfScheduling -cpuprofile ~/cpu-profile.out"
5858
```
5959

6060
### How to configure benchmark tests

0 commit comments

Comments
 (0)