diff --git a/ironic/drivers/modules/inspector/hooks/parse_lldp.py b/ironic/drivers/modules/inspector/hooks/parse_lldp.py index 2f2f77e82e..aba53c90fd 100644 --- a/ironic/drivers/modules/inspector/hooks/parse_lldp.py +++ b/ironic/drivers/modules/inspector/hooks/parse_lldp.py @@ -55,7 +55,16 @@ class ParseLLDPHook(base.InspectionHook): 'node': node_uuid}) continue - if parser.parse_tlv(tlv_type, data): + try: + parsed_tlv = parser.parse_tlv(tlv_type, data) + except UnicodeDecodeError as e: + LOG.warning("LLDP TLV type %(tlv_type)d from Node '%(node)s' " + "can't be decoded: %(exc)s", + {'tlv_type': tlv_type, 'exc': e, + 'node': node_uuid}) + continue + + if parsed_tlv: LOG.debug("Handled TLV type %d. Node: %s", tlv_type, node_uuid) else: LOG.debug("LLDP TLV type %d not handled. Node: %s", tlv_type, diff --git a/releasenotes/notes/fix-lldp-decode-00021e76db26b2a5.yaml b/releasenotes/notes/fix-lldp-decode-00021e76db26b2a5.yaml new file mode 100644 index 0000000000..6eb7435b8d --- /dev/null +++ b/releasenotes/notes/fix-lldp-decode-00021e76db26b2a5.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + In case the lldp raw data collected by the inspection process + includes non utf-8 information, the parser fails breaking + the inspection process. + This patch works around that excluding the malformed data + and adding an entry in the logs to provide information + on the failed tlv.