Skip to content

Commit

Permalink
Correctly initialize klog in clusterctl (kubernetes-sigs#715)
Browse files Browse the repository at this point in the history
Signed-off-by: Vince Prignano <[email protected]>
  • Loading branch information
vincepri authored and k8s-ci-robot committed Jan 27, 2019
1 parent ad8c7f3 commit 6205b2f
Show file tree
Hide file tree
Showing 18 changed files with 18 additions and 28 deletions.
4 changes: 4 additions & 0 deletions cmd/clusterctl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ var RootCmd = &cobra.Command{
Use: "clusterctl",
Short: "cluster management",
Long: `Simple kubernetes cluster management`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
cmd.Flags().Set("logtostderr", "true")
},
Run: func(cmd *cobra.Command, args []string) {
// Do Stuff Here
cmd.Help()
Expand All @@ -50,6 +53,7 @@ func exitWithHelp(cmd *cobra.Command, err string) {

func init() {
klog.InitFlags(flag.CommandLine)
flag.CommandLine.Set("logtostderr", "true")
RootCmd.PersistentFlags().AddGoFlagSet(flag.CommandLine)
InitLogs()
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Global Flags:
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--log_file string If non-empty, use this log file
--logtostderr log to standard error instead of files
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip_headers If true, avoid header prefixes in the log messages
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/create-cluster-no-args.golden
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Global Flags:
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--log_file string If non-empty, use this log file
--logtostderr log to standard error instead of files
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip_headers If true, avoid header prefixes in the log messages
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/create-no-args-invalid-flag.golden
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Global Flags:
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--log_file string If non-empty, use this log file
--logtostderr log to standard error instead of files
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip_headers If true, avoid header prefixes in the log messages
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/create-no-args.golden
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Global Flags:
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--log_file string If non-empty, use this log file
--logtostderr log to standard error instead of files
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip_headers If true, avoid header prefixes in the log messages
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Global Flags:
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--log_file string If non-empty, use this log file
--logtostderr log to standard error instead of files
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip_headers If true, avoid header prefixes in the log messages
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/delete-cluster-no-args.golden
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Global Flags:
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--log_file string If non-empty, use this log file
--logtostderr log to standard error instead of files
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip_headers If true, avoid header prefixes in the log messages
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/delete-no-args-invalid-flag.golden
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Global Flags:
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--log_file string If non-empty, use this log file
--logtostderr log to standard error instead of files
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip_headers If true, avoid header prefixes in the log messages
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/delete-no-args.golden
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Global Flags:
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--log_file string If non-empty, use this log file
--logtostderr log to standard error instead of files
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip_headers If true, avoid header prefixes in the log messages
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/no-args-invalid-flag.golden
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Flags:
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--log_file string If non-empty, use this log file
--logtostderr log to standard error instead of files
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip_headers If true, avoid header prefixes in the log messages
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/no-args.golden
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Flags:
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--log_file string If non-empty, use this log file
--logtostderr log to standard error instead of files
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip_headers If true, avoid header prefixes in the log messages
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Global Flags:
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--log_file string If non-empty, use this log file
--logtostderr log to standard error instead of files
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip_headers If true, avoid header prefixes in the log messages
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Global Flags:
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--log_file string If non-empty, use this log file
--logtostderr log to standard error instead of files
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip_headers If true, avoid header prefixes in the log messages
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/testdata/validate-no-args.golden
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Global Flags:
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--log_file string If non-empty, use this log file
--logtostderr log to standard error instead of files
--logtostderr log to standard error instead of files (default true)
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
--skip_headers If true, avoid header prefixes in the log messages
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
Expand Down
1 change: 1 addition & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
)

func main() {
flag.Set("logtostderr", "true")
klog.InitFlags(nil)
flag.Parse()

Expand Down
5 changes: 0 additions & 5 deletions config/crds/cluster_v1alpha1_machine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ spec:
type: string
type: object
type: object
oneOf:
- required:
- value
- required:
- valueFrom
type: object
taints:
description: Taints is the full, authoritative list of taints to apply
Expand Down
5 changes: 0 additions & 5 deletions config/crds/cluster_v1alpha1_machinedeployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ spec:
type: string
type: object
type: object
oneOf:
- required:
- value
- required:
- valueFrom
type: object
taints:
description: Taints is the full, authoritative list of taints
Expand Down
5 changes: 0 additions & 5 deletions config/crds/cluster_v1alpha1_machineset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ spec:
type: string
type: object
type: object
oneOf:
- required:
- value
- required:
- valueFrom
type: object
taints:
description: Taints is the full, authoritative list of taints
Expand Down

0 comments on commit 6205b2f

Please sign in to comment.