mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Improve broken events catching and reporting
This commit is contained in:
parent
f406a090df
commit
ffe2d166c1
1 changed files with 21 additions and 2 deletions
|
@ -76,6 +76,7 @@ import salt.utils.platform
|
|||
import salt.utils.process
|
||||
import salt.utils.stringutils
|
||||
import salt.utils.zeromq
|
||||
from salt.exceptions import SaltDeserializationError
|
||||
from salt.utils.versions import warn_until
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -421,7 +422,13 @@ class SaltEvent:
|
|||
salt.utils.stringutils.to_bytes(TAGEND)
|
||||
) # split tag from data
|
||||
mtag = salt.utils.stringutils.to_str(mtag)
|
||||
data = salt.payload.loads(mdata, encoding="utf-8")
|
||||
try:
|
||||
data = salt.payload.loads(mdata, encoding="utf-8")
|
||||
except SaltDeserializationError:
|
||||
log.warning(
|
||||
"SaltDeserializationError on unpacking data, the payload could be incomplete"
|
||||
)
|
||||
raise
|
||||
return mtag, data
|
||||
|
||||
@classmethod
|
||||
|
@ -562,6 +569,9 @@ class SaltEvent:
|
|||
raise
|
||||
else:
|
||||
return None
|
||||
except SaltDeserializationError:
|
||||
log.error("Unable to deserialize received event")
|
||||
return None
|
||||
except RuntimeError:
|
||||
return None
|
||||
|
||||
|
@ -825,6 +835,14 @@ class SaltEvent:
|
|||
ret = load.get("return", {})
|
||||
retcode = load["retcode"]
|
||||
|
||||
if not isinstance(ret, dict):
|
||||
log.error(
|
||||
"Event with bad payload received from '%s': %s",
|
||||
load.get("id", "UNKNOWN"),
|
||||
"".join(ret) if isinstance(ret, list) else ret,
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
for tag, data in ret.items():
|
||||
data["retcode"] = retcode
|
||||
|
@ -844,7 +862,8 @@ class SaltEvent:
|
|||
)
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
log.error(
|
||||
"Event iteration failed with exception: %s",
|
||||
"Event from '%s' iteration failed with exception: %s",
|
||||
load.get("id", "UNKNOWN"),
|
||||
exc,
|
||||
exc_info_on_loglevel=logging.DEBUG,
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue