Skip to content
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

Correctly initialize klog in clusterctl #715

Merged
merged 1 commit into from
Jan 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR reverted a change previously made in #684

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, this is going to be replaced each time CRDs are regenereated given that kubebuilder doesn't support it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@detiber do you know any other ways to achieve this apart from a hacky kustomize / bash script?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to create and track an issue against sigs.k8s.io/controller-runtime to get a proper fix in place.

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