Commit 2afc9238 authored by Iustin Pop's avatar Iustin Pop
Browse files

Prevent ssconf values from having non-string values



For whatever reason, my test cluster managed to acquire
shared_file_storage_dir with a None value, instead of empty
string. This is not flagged in masterd itself, but the node daemon
will fail in writing the value to disk, as it calls len() on the
received value.

Since this is a bad case, we should detect it as soon as possible (we
basically shouldn't be able to set it), but in the meantime we at
least prevent ssconf writes with such values.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 9cbc1edb
......@@ -1744,7 +1744,7 @@ class ConfigWriter:
self._config_data.nodegroups.values()]
nodegroups_data = fn(utils.NiceSort(nodegroups))
return {
ssconf_values = {
constants.SS_CLUSTER_NAME: cluster.cluster_name,
constants.SS_CLUSTER_TAGS: cluster_tags,
constants.SS_FILE_STORAGE_DIR: cluster.file_storage_dir,
......@@ -1767,6 +1767,13 @@ class ConfigWriter:
constants.SS_UID_POOL: uid_pool,
constants.SS_NODEGROUPS: nodegroups_data,
}
bad_values = [(k, v) for k, v in ssconf_values.items()
if not isinstance(v, (str, basestring))]
if bad_values:
err = utils.CommaJoin("%s=%s" % (k, v) for k, v in bad_values)
raise errors.ConfigurationError("Some ssconf key(s) have non-string"
" values: %s" % err)
return ssconf_values
@locking.ssynchronized(_config_lock, shared=1)
def GetSsconfValues(self):
......
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