Commit Graph

48 Commits

Author SHA1 Message Date
Ross Peoples
98837de446 TimeZone support for CronJobs 2022-03-28 16:33:00 -05:00
Patrick Ohly
00e4a599f6 command lines: always show flags with hyphens
All Kubernetes commands should show flags with hyphens in their help text even
when the flag originally was defined with underscore. Converting a command to
this style is not breaking its command line API because the old-style parameter
with underscore is accepted as alias.

The easiest solution to achieve this is to set normalization shortly before
running the command in the new central cli.Run or the few places where that
function isn't used yet.

There may be some texts which depends on normalization at flag definition time,
like the --logging-format usage warning. Those get generated assuming that
hyphens will be used.
2021-09-30 13:46:49 +02:00
Patrick Ohly
21d1bcd6b8 initialize logging after flag parsing
It wasn't documented that InitLogs already uses the log flush frequency, so
some commands have called it before parsing (for example, kubectl in the
original code for logs.go). The flag never had an effect in such commands.

Fixing this turned into a major refactoring of how commands set up flags and
run their Cobra command:

- component-base/logs: implicitely registering flags during package init is an
  anti-pattern that makes it impossible to use the package in commands which
  want full control over their command line. Logging flags must be added
  explicitly now, something that the new cli.Run does automatically.

- component-base/logs: AddFlags would have crashed in kubectl-convert if it
  had been called because it relied on the global pflag.CommandLine. This
  has been fixed and kubectl-convert now has the same --log-flush-frequency
  flag as other commands.

- component-base/logs/testinit: an exception are tests where flag.CommandLine has
  to be used. This new package can be imported to add flags to that
  once per test program.

- Normalization of the klog command line flags was inconsistent. Some commands
  unintentionally didn't normalize to the recommended format with hyphens. This
  gets fixed for sample programs, but not for production programs because
  it would be a breaking change.

This refactoring has the following user-visible effects:

- The validation error for `go run ./cmd/kube-apiserver --logging-format=json
  --add-dir-header` now references `add-dir-header` instead of `add_dir_header`.

- `staging/src/k8s.io/cloud-provider/sample` uses flags with hyphen instead of
  underscore.

- `--log-flush-frequency` is not listed anymore in the --logging-format flag's
  `non-default formats don't honor these flags` usage text because it will also
  work for non-default formats once it is needed.

- `cmd/kubelet`: the description of `--logging-format` uses hyphens instead of
  underscores for the flags, which now matches what the command is using.

- `staging/src/k8s.io/component-base/logs/example/cmd`: added logging flags.

- `apiextensions-apiserver` no longer prints a useless stack trace for `main`
  when command line parsing raises an error.
2021-09-30 13:46:49 +02:00
Mengjiao Liu
90df026709 JSON log format registration for kube-controller-manager 2021-06-10 07:30:30 +08:00
chenyw1990
e2020f62ac add normalize function to global FlagSet 2021-03-18 09:23:52 +08:00
Han Kang
866ea74326 remove pkg/version and some of redundant copies of it
Change-Id: Ia58367c1b1274bfb49c8a4784051463abaf795de
2019-09-16 16:24:35 -07:00
Han Kang
59db3ac27e migrate controller-manager metrics to stability framework 2019-08-28 12:26:57 -07:00
Odin Ugedal
7caf51daa4
Remove duplicate error messages from cli commands
Since we never use the cobras "SilenceErrors" or "SilenceUsage",
a command executed with "cmd.Execute()" will never return an error
without printing it.

The current behavior results in all error messages being printed twice:

Example:

$ kubectl abc
Error: unknown command "abc" for "kubectl"
Run 'kubectl --help' for usage.
unknown command "abc" for "kubectl"

This applies to all cli commands using Cobra. To verify, follow the code
path of the Execute function:

https://github.com/spf13/cobra/blob/c439c4fa0937/command.go#L793
Signed-off-by: Odin Ugedal <odin@ugedal.com>
2019-06-27 21:55:14 +02:00
Marek Counts
ba81a5409a move logs into component-base
all the code changes to move move /apiserver/pkg/util/logs into /component-base/logs
2019-01-17 09:16:21 -05:00
Walter Fender
f192657380 Add gauge metric for master of leader election.
Fixes #71730
0 indicates standby, 1 indicates master, label indicates which lease.
Tweaked name and documentation
Factored in Mike Danese feedback.
Removed dependency on prometheus from client-go using adapter.
Centralized adapter import.
Fixed godeps
Fixed boilerplate.
Put in fixes for caesarxuchao
2018-12-27 09:40:33 -08:00
Jay Lim
10dd5d6631 *-controller-manager: fix missing global flags for --help 2018-11-21 17:39:14 +08:00
Mikhail Mazurskiy
3a243090a5
Simplify random seed initialization
There is no need to set the time zone as the result does not
depend on it
2018-10-11 21:01:15 +11:00
stewart-yu
0cbe0a6034 controller-manager: switch to config/option struct pattern 2018-02-13 11:16:17 +01:00
David Eads
e48847e6ce switch hyper to cobra 2018-01-24 11:02:19 -05:00
David Eads
d7db324c38 make the controller manager create and use a valid cobra command 2018-01-18 07:54:36 -05:00
David Eads
d7ddcca231 low hanging fruit for using cobra commands 2018-01-17 13:43:43 -05:00
wackxu
22a706ed50 remove duplicate healthz check register 2017-11-03 11:27:30 +08:00
deads2k
151d39682e add reflector metrics 2017-07-25 09:01:37 -04:00
deads2k
78d8a8efa8 copy pkg/util/logs to apiserver 2017-02-13 12:07:15 -05:00
Dr. Stefan Schimanski
82826ec273 pkg/util/flag: move to k8s.io/apiserver 2017-01-24 20:56:03 +01:00
Dr. Stefan Schimanski
3d9449a353 genericapiserver: fix imports 2017-01-19 13:06:47 +01:00
deads2k
d9b75ed82b add --controllers to controller manager 2017-01-12 08:46:33 -05:00
deads2k
4d7fcae85a mechanicals 2017-01-05 11:14:27 -05:00
Chao Xu
feb0d1daa8 decouple workqueue metrics from prometheus 2016-10-03 11:02:06 -07:00
Kris
1740358573 Split the version metric out to its own package 2016-08-24 11:47:16 -07:00
Kris
8d6ce0dcc6 Remove implicit Prometheus metrics from client 2016-08-19 10:11:45 -07:00
Chao Xu
a771578a1c move pkg/util/ files to their own package to reduce client-go dependencies 2016-08-05 23:32:02 -07:00
Lucas Käldström
88ea80b572 Remove GOMAXPROCS() calls because they are unnecessary 2016-07-19 11:08:21 +03:00
David McMahon
ef0c9f0c5b Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
harry
f19d59cf35 Move flag into sub pkg 2016-03-14 21:30:38 +08:00
Clayton Coleman
2326e2bae3 Split controller manager options from init
Make defaults and flags clearly distinct from initialization code.
2016-01-06 22:39:14 -05:00
Mike Danese
8e33cbfa28 rewrite go imports 2015-08-05 17:30:03 -07:00
Eric Paris
6b3a6e6b98 Make copyright ownership statement generic
Instead of saying "Google Inc." (which is not always correct) say "The
Kubernetes Authors", which is generic.
2015-05-01 17:49:56 -04:00
Eric Paris
036937227f Use Fprintf to print formatted strings
Shouldn't be using Fprint() with a format string.
2015-04-14 10:51:57 -04:00
Eric Paris
8e7d14196f Fix printing errors from failed binary runs
I had the kublet die on startup and the only error was "0x401da0"  Which
I assume is an address of the err.Error function.  The other way to fix
this, I think, would be to use err.Error(), however that could cause
fmt.Fprintf() problems, debuging on the error message people used.

Now I get a nice clean error I can understand:

"cAdvisor.New() err = mountpoint for cpu not found"
2015-04-10 17:56:47 -04:00
Clayton Coleman
015bc3b7bd Remove global map from healthz
It currently is impossible to use two healthz handlers on different
ports in the same process.  This removes the global variables in favor
of requiring the consumer to specify all health checks up front.
2015-03-19 19:49:44 -04:00
Tim Hockin
0b17c0f225 move pkg/controllermanager to cmd/kube-controller-manager/app 2015-02-20 08:49:12 -08:00
Daniel Smith
fcddefa184 Set GOMAXPROCS. Print errors on stderr. 2015-02-19 10:30:31 -08:00
Joe Beda
bbb4479166 Convert controller-manager to hyperkube. 2015-02-02 10:01:36 -08:00
Deyuan Deng
c793c4f0ab Sync node status from node controller to master. 2015-01-29 23:17:15 -05:00
derekwaynecarr
67b359ebf9 Add a resource quota controller to track usage state 2015-01-28 15:03:19 -05:00
Deyuan Deng
c263a79d3e Add node sync period flag 2015-01-22 19:14:02 -05:00
Joe Beda
6bd6b905f5 Address code review comments
Add some documentation.
Create new util.InitFlags() function to merge and parse in one step.
2015-01-15 09:12:20 -08:00
Joe Beda
dcd00c936e Move all kubernetes to posix flags 2015-01-15 09:12:19 -08:00
Deyuan Deng
a2651bfcc7 Rename minioncontroller to nodecontroller 2015-01-08 14:52:10 -05:00
Daniel Smith
35f54addca Update more packages, tests, binaries for quantity
make etcd registry pass test
fix kubelet config for quantity
fix openstack for quantity
fix controller for quantity
fix last tests for quantity
wire into binaries
fix controller manager
fix build for 32 bit systems
2015-01-07 15:21:35 -08:00
Joe Beda
e5b988393d Fix 32bit build 2014-11-21 14:58:17 -08:00
Eric Paris
a99c3c7963 rename kube server binaries to kube-
apiserver becomes kube-apiserver
controller-manager -> kube-controller-manager
scheduler and proxy similarly.

Only thing I promise is that right now hack/build-go.sh and
build/release.sh exit with 0.  That's it.  Who knows if any of this
actually works....
2014-11-13 20:08:26 -05:00