[autoscaler] Bad error message when dict field omitted (#1632)

* Wed Feb 28 23:22:55 PST 2018

* Wed Feb 28 23:24:07 PST 2018
This commit is contained in:
Eric Liang
2018-03-03 20:25:58 -08:00
committed by GitHub
parent 75293a0ba0
commit 9b33f3a7b7
+8 -1
View File
@@ -467,6 +467,13 @@ class StandardAutoscaler(object):
suffix, self.load_metrics.debug_string())
def typename(v):
if isinstance(v, type):
return v.__name__
else:
return type(v).__name__
def validate_config(config, schema=CLUSTER_CONFIG_SCHEMA):
if type(config) is not dict:
raise ValueError("Config is not a dictionary")
@@ -476,7 +483,7 @@ def validate_config(config, schema=CLUSTER_CONFIG_SCHEMA):
if k not in config:
raise ValueError(
"Missing required config key `{}` of type {}".format(
k, v.__name__))
k, typename(v)))
if isinstance(v, type):
if not isinstance(config[k], v):
raise ValueError(