Commit 8e05da13 authored by Brendan Burns's avatar Brendan Burns

Merge pull request #12696 from eparis/less-dash-false-positive

Fewer false positives in verify-flag-underscore.sh
parents d7763a1b 56f6ad0c
...@@ -81,7 +81,7 @@ func (s *ProxyServer) AddFlags(fs *pflag.FlagSet) { ...@@ -81,7 +81,7 @@ func (s *ProxyServer) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig)") fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig)")
fs.IntVar(&s.HealthzPort, "healthz-port", s.HealthzPort, "The port to bind the health check server. Use 0 to disable.") fs.IntVar(&s.HealthzPort, "healthz-port", s.HealthzPort, "The port to bind the health check server. Use 0 to disable.")
fs.IPVar(&s.HealthzBindAddress, "healthz-bind-address", s.HealthzBindAddress, "The IP address for the health check server to serve on, defaulting to 127.0.0.1 (set to 0.0.0.0 for all interfaces)") fs.IPVar(&s.HealthzBindAddress, "healthz-bind-address", s.HealthzBindAddress, "The IP address for the health check server to serve on, defaulting to 127.0.0.1 (set to 0.0.0.0 for all interfaces)")
fs.IntVar(&s.OOMScoreAdj, "oom-score-adj", s.OOMScoreAdj, "The oom_score_adj value for kube-proxy process. Values must be within the range [-1000, 1000]") fs.IntVar(&s.OOMScoreAdj, "oom-score-adj", s.OOMScoreAdj, "The oom-score-adj value for kube-proxy process. Values must be within the range [-1000, 1000]")
fs.StringVar(&s.ResourceContainer, "resource-container", s.ResourceContainer, "Absolute name of the resource-only container to create and run the Kube-proxy in (Default: /kube-proxy).") fs.StringVar(&s.ResourceContainer, "resource-container", s.ResourceContainer, "Absolute name of the resource-only container to create and run the Kube-proxy in (Default: /kube-proxy).")
fs.StringVar(&s.Kubeconfig, "kubeconfig", s.Kubeconfig, "Path to kubeconfig file with authorization information (the master location is set by the master flag).") fs.StringVar(&s.Kubeconfig, "kubeconfig", s.Kubeconfig, "Path to kubeconfig file with authorization information (the master location is set by the master flag).")
fs.Var(&s.PortRange, "proxy-port-range", "Range of host ports (beginPort-endPort, inclusive) that may be consumed in order to proxy service traffic. If unspecified (0-0) then ports will be randomly chosen.") fs.Var(&s.PortRange, "proxy-port-range", "Range of host ports (beginPort-endPort, inclusive) that may be consumed in order to proxy service traffic. If unspecified (0-0) then ports will be randomly chosen.")
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
The implementation of the scheduler HA feature includes: The implementation of the scheduler HA feature includes:
- Checkpointing by default (`--checkpoint`) - Checkpointing by default (`--checkpoint`)
- Large failover-timeout by default (`--failover_timeout`) - Large failover-timeout by default (`--failover-timeout`)
- Hot-failover w/ multiple scheduler instances (`--ha`) - Hot-failover w/ multiple scheduler instances (`--ha`)
- Best effort task reconciliation on failover - Best effort task reconciliation on failover
......
...@@ -56,7 +56,7 @@ with the apiserver API to configure the proxy. ...@@ -56,7 +56,7 @@ with the apiserver API to configure the proxy.
-h, --help=false: help for kube-proxy -h, --help=false: help for kube-proxy
--kubeconfig="": Path to kubeconfig file with authorization information (the master location is set by the master flag). --kubeconfig="": Path to kubeconfig file with authorization information (the master location is set by the master flag).
--master="": The address of the Kubernetes API server (overrides any value in kubeconfig) --master="": The address of the Kubernetes API server (overrides any value in kubeconfig)
--oom-score-adj=0: The oom_score_adj value for kube-proxy process. Values must be within the range [-1000, 1000] --oom-score-adj=0: The oom-score-adj value for kube-proxy process. Values must be within the range [-1000, 1000]
--proxy-port-range=: Range of host ports (beginPort-endPort, inclusive) that may be consumed in order to proxy service traffic. If unspecified (0-0) then ports will be randomly chosen. --proxy-port-range=: Range of host ports (beginPort-endPort, inclusive) that may be consumed in order to proxy service traffic. If unspecified (0-0) then ports will be randomly chosen.
--resource-container="": Absolute name of the resource-only container to create and run the Kube-proxy in (Default: /kube-proxy). --resource-container="": Absolute name of the resource-only container to create and run the Kube-proxy in (Default: /kube-proxy).
``` ```
......
...@@ -98,14 +98,14 @@ HTTP server: The kubelet can also listen for HTTP and respond to a simple API ...@@ -98,14 +98,14 @@ HTTP server: The kubelet can also listen for HTTP and respond to a simple API
--minimum-container-ttl-duration=0: Minimum age for a finished container before it is garbage collected. Examples: '300ms', '10s' or '2h45m' --minimum-container-ttl-duration=0: Minimum age for a finished container before it is garbage collected. Examples: '300ms', '10s' or '2h45m'
--network-plugin="": <Warning: Alpha feature> The name of the network plugin to be invoked for various events in kubelet/pod lifecycle --network-plugin="": <Warning: Alpha feature> The name of the network plugin to be invoked for various events in kubelet/pod lifecycle
--node-status-update-frequency=0: Specifies how often kubelet posts node status to master. Note: be cautious when changing the constant, it must work with nodeMonitorGracePeriod in nodecontroller. Default: 10s --node-status-update-frequency=0: Specifies how often kubelet posts node status to master. Note: be cautious when changing the constant, it must work with nodeMonitorGracePeriod in nodecontroller. Default: 10s
--oom-score-adj=0: The oom_score_adj value for kubelet process. Values must be within the range [-1000, 1000] --oom-score-adj=0: The oom-score-adj value for kubelet process. Values must be within the range [-1000, 1000]
--pod-cidr="": The CIDR to use for pod IP addresses, only used in standalone mode. In cluster mode, this is obtained from the master. --pod-cidr="": The CIDR to use for pod IP addresses, only used in standalone mode. In cluster mode, this is obtained from the master.
--pod-infra-container-image="": The image whose network/ipc namespaces containers in each pod will use. --pod-infra-container-image="": The image whose network/ipc namespaces containers in each pod will use.
--port=0: The port for the Kubelet to serve on. Note that "kubectl logs" will not work if you set this flag. --port=0: The port for the Kubelet to serve on. Note that "kubectl logs" will not work if you set this flag.
--read-only-port=0: The read-only port for the Kubelet to serve on (set to 0 to disable) --read-only-port=0: The read-only port for the Kubelet to serve on (set to 0 to disable)
--really-crash-for-testing=false: If true, when panics occur crash. Intended for testing. --really-crash-for-testing=false: If true, when panics occur crash. Intended for testing.
--register-node=false: Register the node with the apiserver (defaults to true if --api-server is set) --register-node=false: Register the node with the apiserver (defaults to true if --api-server is set)
--registry-burst=0: Maximum size of a bursty pulls, temporarily allows pulls to burst to this number, while still not exceeding registry_qps. Only used if --registry-qps > 0 --registry-burst=0: Maximum size of a bursty pulls, temporarily allows pulls to burst to this number, while still not exceeding registry-qps. Only used if --registry-qps > 0
--registry-qps=0: If > 0, limit registry pull QPS to this value. If 0, unlimited. [default=0.0] --registry-qps=0: If > 0, limit registry pull QPS to this value. If 0, unlimited. [default=0.0]
--resource-container="": Absolute name of the resource-only container to create and run the Kubelet in (Default: /kubelet). --resource-container="": Absolute name of the resource-only container to create and run the Kubelet in (Default: /kubelet).
--root-dir="": Directory path for managing kubelet files (volume mounts,etc). --root-dir="": Directory path for managing kubelet files (volume mounts,etc).
......
...@@ -28,9 +28,6 @@ parser.add_argument("filenames", help="list of files to check, all files if unsp ...@@ -28,9 +28,6 @@ parser.add_argument("filenames", help="list of files to check, all files if unsp
parser.add_argument("-e", "--skip-exceptions", help="ignore hack/verify-flags/exceptions.txt and print all output", action="store_true") parser.add_argument("-e", "--skip-exceptions", help="ignore hack/verify-flags/exceptions.txt and print all output", action="store_true")
args = parser.parse_args() args = parser.parse_args()
dashRE = re.compile('[-_]')
# Cargo culted from http://stackoverflow.com/questions/898669/how-can-i-detect-if-a-file-is-binary-non-text-in-python # Cargo culted from http://stackoverflow.com/questions/898669/how-can-i-detect-if-a-file-is-binary-non-text-in-python
def is_binary(pathname): def is_binary(pathname):
"""Return true if the given filename is binary. """Return true if the given filename is binary.
...@@ -96,11 +93,10 @@ def normalize_files(rootdir, files): ...@@ -96,11 +93,10 @@ def normalize_files(rootdir, files):
return newfiles return newfiles
def line_has_bad_flag(line, flagre): def line_has_bad_flag(line, flagre):
m = flagre.search(line) results = flagre.findall(line)
if not m: for result in results:
return False if "_" in result:
if "_" in m.group(0): return True
return True
return False return False
# The list of files might not be the whole repo. If someone only changed a # The list of files might not be the whole repo. If someone only changed a
...@@ -109,14 +105,16 @@ def line_has_bad_flag(line, flagre): ...@@ -109,14 +105,16 @@ def line_has_bad_flag(line, flagre):
# If running the golang files finds a new flag not in that file, return an # If running the golang files finds a new flag not in that file, return an
# error and tell the user to add the flag to the flag list. # error and tell the user to add the flag to the flag list.
def get_flags(rootdir, files): def get_flags(rootdir, files):
# use a set for uniqueness
flags = set()
# preload the 'known' flags # preload the 'known' flags
pathname = os.path.join(rootdir, "hack/verify-flags/known-flags.txt") pathname = os.path.join(rootdir, "hack/verify-flags/known-flags.txt")
f = open(pathname, 'r') f = open(pathname, 'r')
for line in f.read().splitlines(): flags = set(f.read().splitlines())
flags.add(line) f.close()
# preload the 'known' flags which don't follow the - standard
pathname = os.path.join(rootdir, "hack/verify-flags/excluded-flags.txt")
f = open(pathname, 'r')
excluded_flags = set(f.read().splitlines())
f.close() f.close()
regexs = [ re.compile('Var[P]?\([^,]*, "([^"]*)"'), regexs = [ re.compile('Var[P]?\([^,]*, "([^"]*)"'),
...@@ -127,6 +125,7 @@ def get_flags(rootdir, files): ...@@ -127,6 +125,7 @@ def get_flags(rootdir, files):
re.compile('.StringSlice[P]?\("([^"]*)",[^,]+,[^)]+\)') ] re.compile('.StringSlice[P]?\("([^"]*)",[^,]+,[^)]+\)') ]
new_flags = set() new_flags = set()
new_excluded_flags = set()
# walk all the files looking for any flags being declared # walk all the files looking for any flags being declared
for pathname in files: for pathname in files:
if not pathname.endswith(".go"): if not pathname.endswith(".go"):
...@@ -138,11 +137,19 @@ def get_flags(rootdir, files): ...@@ -138,11 +137,19 @@ def get_flags(rootdir, files):
for regex in regexs: for regex in regexs:
matches = matches + regex.findall(data) matches = matches + regex.findall(data)
for flag in matches: for flag in matches:
# if the flag doesn't have a - or _ it is not interesting if any(x in flag for x in excluded_flags):
if not dashRE.search(flag): continue
if "_" in flag:
new_excluded_flags.add(flag)
if not "-" in flag:
continue continue
if flag not in flags: if flag not in flags:
new_flags.add(flag) new_flags.add(flag)
if len(new_excluded_flags) != 0:
print("Found a flag declared with an _ but which is not explicitly listed as a valid flag name in hack/verify-flags/excluded-flags.txt")
print("Are you certain this flag should not have been declared with an - instead?")
print("%s" % "\n".join(new_excluded_flags))
sys.exit(1)
if len(new_flags) != 0: if len(new_flags) != 0:
print("Found flags in golang files not in the list of known flags. Please add these to hack/verify-flags/known-flags.txt") print("Found flags in golang files not in the list of known flags. Please add these to hack/verify-flags/known-flags.txt")
print("%s" % "\n".join(new_flags)) print("%s" % "\n".join(new_flags))
...@@ -150,12 +157,14 @@ def get_flags(rootdir, files): ...@@ -150,12 +157,14 @@ def get_flags(rootdir, files):
return list(flags) return list(flags)
def flags_to_re(flags): def flags_to_re(flags):
"""turn the list of all flags we found into a regex find both - and _ version""" """turn the list of all flags we found into a regex find both - and _ versions"""
dashRE = re.compile('[-_]')
flagREs = [] flagREs = []
for flag in flags: for flag in flags:
# turn all flag names into regexs which will find both types # turn all flag names into regexs which will find both types
newre = dashRE.sub('[-_]', flag) newre = dashRE.sub('[-_]', flag)
flagREs.append(newre) # only match if there is not a leading or trailing alphanumeric character
flagREs.append("[^\w]" + newre + "[^\w]")
# turn that list of regex strings into a single large RE # turn that list of regex strings into a single large RE
flagRE = "|".join(flagREs) flagRE = "|".join(flagREs)
flagRE = re.compile(flagRE) flagRE = re.compile(flagRE)
......
check_version_skew
concurrent_rc_syncs
etcd_mutation_timeout
file_content
file_mode
file_perm
fs_type
gke_context
host_port_endpoints
kubecfg_file
kube_master_url
log_flush_frequency
max_in_flight
max_par
new_file_0644
new_file_0666
new_file_0777
pods_per_node
pods_per_node
test_args
up_to
up_to
valid_flag
...@@ -31,7 +31,6 @@ certificate-authority ...@@ -31,7 +31,6 @@ certificate-authority
cgroup-prefix cgroup-prefix
cgroup-root cgroup-root
chaos-chance chaos-chance
check_version_skew
client-ca-file client-ca-file
client-certificate client-certificate
client-key client-key
...@@ -43,7 +42,6 @@ cluster-domain ...@@ -43,7 +42,6 @@ cluster-domain
cluster-name cluster-name
cluster-tag cluster-tag
concurrent-endpoint-syncs concurrent-endpoint-syncs
concurrent_rc_syncs
configure-cbr0 configure-cbr0
container-port container-port
container-runtime container-runtime
...@@ -62,15 +60,11 @@ docker-endpoint ...@@ -62,15 +60,11 @@ docker-endpoint
docker-exec-handler docker-exec-handler
driver-port driver-port
dry-run dry-run
dry-run
dry-run
dry-run
duration-sec duration-sec
e2e-output-dir e2e-output-dir
enable-debugging-handlers enable-debugging-handlers
enable-server enable-server
etcd-config etcd-config
etcd_mutation_timeout
etcd-prefix etcd-prefix
etcd-server etcd-server
etcd-servers etcd-servers
...@@ -85,34 +79,25 @@ experimental-prefix ...@@ -85,34 +79,25 @@ experimental-prefix
external-hostname external-hostname
failover-timeout failover-timeout
file-check-frequency file-check-frequency
file_content
file_mode
file_perm
file-suffix file-suffix
forward-services forward-services
framework-name framework-name
framework-weburi framework-weburi
fs_type
func-dest func-dest
fuzz-iters fuzz-iters
gce-project gce-project
gce-zone gce-zone
gke-cluster gke-cluster
gke_context
google-json-key google-json-key
grace-period grace-period
grace-period
grace-period
ha-domain ha-domain
healthz-bind-address healthz-bind-address
healthz-port healthz-port
hostname-override hostname-override
host-network-sources host-network-sources
host_port_endpoints
http-check-frequency http-check-frequency
http-port http-port
ignore-not-found ignore-not-found
ignore-not-found
image-gc-high-threshold image-gc-high-threshold
image-gc-low-threshold image-gc-low-threshold
insecure-bind-address insecure-bind-address
...@@ -122,7 +107,6 @@ iptables-sync-period ...@@ -122,7 +107,6 @@ iptables-sync-period
jenkins-host jenkins-host
jenkins-jobs jenkins-jobs
km-path km-path
kubecfg_file
kubectl-path kubectl-path
kubelet-cadvisor-port kubelet-cadvisor-port
kubelet-certificate-authority kubelet-certificate-authority
...@@ -138,11 +122,9 @@ kubelet-root-dir ...@@ -138,11 +122,9 @@ kubelet-root-dir
kubelet-sync-frequency kubelet-sync-frequency
kubelet-timeout kubelet-timeout
kube-master kube-master
kube_master_url
label-columns label-columns
last-release-pr last-release-pr
legacy-userspace-proxy legacy-userspace-proxy
log_flush_frequency
long-running-request-regexp long-running-request-regexp
low-diskspace-threshold-mb low-diskspace-threshold-mb
manifest-url manifest-url
...@@ -152,13 +134,11 @@ max-concurrency ...@@ -152,13 +134,11 @@ max-concurrency
max-connection-bytes-per-sec max-connection-bytes-per-sec
maximum-dead-containers maximum-dead-containers
maximum-dead-containers-per-container maximum-dead-containers-per-container
max_in_flight
max-log-age max-log-age
max-log-backups max-log-backups
max-log-size max-log-size
max-outgoing-burst max-outgoing-burst
max-outgoing-qps max-outgoing-qps
max_par
max-pods max-pods
max-requests-inflight max-requests-inflight
mesos-authentication-principal mesos-authentication-principal
...@@ -176,9 +156,6 @@ min-request-timeout ...@@ -176,9 +156,6 @@ min-request-timeout
namespace-sync-period namespace-sync-period
network-plugin network-plugin
network-plugin-dir network-plugin-dir
new_file_0644
new_file_0666
new_file_0777
node-instance-group node-instance-group
node-monitor-grace-period node-monitor-grace-period
node-monitor-period node-monitor-period
...@@ -193,8 +170,6 @@ out-version ...@@ -193,8 +170,6 @@ out-version
pod-cidr pod-cidr
pod-eviction-timeout pod-eviction-timeout
pod-infra-container-image pod-infra-container-image
pods_per_node
pods_per_node
policy-config-file policy-config-file
poll-interval poll-interval
portal-net portal-net
...@@ -253,7 +228,6 @@ sync-frequency ...@@ -253,7 +228,6 @@ sync-frequency
system-container system-container
target-port target-port
tcp-services tcp-services
test_args
tls-cert-file tls-cert-file
tls-private-key-file tls-private-key-file
token-auth-file token-auth-file
...@@ -261,11 +235,8 @@ ttl-secs ...@@ -261,11 +235,8 @@ ttl-secs
unix-socket unix-socket
update-period update-period
upgrade-target upgrade-target
up_to
up_to
use-kubernetes-cluster-service use-kubernetes-cluster-service
user-whitelist user-whitelist
valid_flag
watch-only watch-only
whitelist-override-label whitelist-override-label
www-prefix www-prefix
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment