Merge pull request #22810 from basepi/salt-ssh.more.msgpack.gating

[2014.7] More msgpack gating for salt-ssh
This commit is contained in:
Colton Myers 2015-04-17 16:28:24 -06:00
commit fe1de89ad7
3 changed files with 15 additions and 6 deletions

View file

@ -47,7 +47,7 @@ def load():
datastore_path = os.path.join(__opts__['cachedir'], 'datastore')
fn_ = salt.utils.fopen(datastore_path, 'rb')
return serial.load(fn_)
except (IOError, OSError):
except (IOError, OSError, NameError):
return {}
@ -75,7 +75,7 @@ def dump(new_data):
return True
except (IOError, OSError):
except (IOError, OSError, NameError):
return False

View file

@ -522,7 +522,11 @@ def find_cached_job(jid):
buf = fp_.read()
fp_.close()
if buf:
data = serial.loads(buf)
try:
data = serial.loads(buf)
except NameError:
# msgpack error in salt-ssh
return
else:
return
if not isinstance(data, dict):

View file

@ -272,7 +272,8 @@ def _load_accumulators():
with open(path, 'rb') as f:
loaded = serial.load(f)
return loaded if loaded else ret
except IOError:
except (IOError, NameError):
# NameError is a msgpack error from salt-ssh
return ret
loaded = _deserialize(_get_accumulator_filepath())
@ -286,8 +287,12 @@ def _persist_accummulators(accumulators, accumulators_deps):
'accumulators_deps': accumulators_deps}
serial = salt.payload.Serial(__opts__)
with open(_get_accumulator_filepath(), 'w+b') as f:
serial.dump(accumm_data, f)
try:
with open(_get_accumulator_filepath(), 'w+b') as f:
serial.dump(accumm_data, f)
except NameError:
# msgpack error from salt-ssh
pass
def _check_user(user, group):