load_yaml: if conversion fails, but string is empty, return default
the problem sovled here is that most callers of yaml_load do not pass 'None' as a allowed type. I didn't want to change all the callers. If the yaml.safe_load ended up being None we were raising a TypeError and that was getting logged (meaning output to console). Even though the this was not really bad. So, if the type is not in the list, *and* it is not empty, then log exception. If it in the list and empty, just debug. empty input was occurring when cloud-config was empty (no user-data)
This commit is contained in:
parent
a857429d6a
commit
fc3bafe528
@ -609,6 +609,9 @@ def load_yaml(blob, default=None, allowed=(dict,)):
|
||||
(allowed, obj_name(converted)))
|
||||
loaded = converted
|
||||
except (yaml.YAMLError, TypeError, ValueError):
|
||||
if len(blob) == 0:
|
||||
LOG.debug("load_yaml given empty string, returning default")
|
||||
else:
|
||||
logexc(LOG, "Failed loading yaml blob")
|
||||
return loaded
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user