salt-cp时报错UnicodeDecodeError

发布于 2022-09-11 15:03:55 字数 4287 浏览 23 评论 0

问题描述

使用salt-cp拷贝了一个tar.gz的压缩包,结果在执行后报错,但是文件却已经完整的传输到了minion端。

问题出现的环境背景及自己尝试过哪些方法

我尝试将python2.7的代码环境换成UTF-8,重启salt-master和salt-minion后再次尝试,还是不行。

报错情况

[root@localhost ]# salt-cp '*' scan.tar.gz /web/soft/scan
[CRITICAL] Could not deserialize msgpack message. This often happens when trying to read a file not in binary mode. To see message payload, enable debug logging and retry. Exception: 'utf8' codec can't decode byte 0x8b in position 1: invalid start byte
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
UnicodeDecodeError: 'utf8' codec can't decode byte 0x8b in position 1: invalid start byte
Traceback (most recent call last):
  File "/usr/bin/salt-cp", line 10, in <module>
    salt_cp()
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 387, in salt_cp
    client.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/cp.py", line 52, in run
    cp_.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/cp.py", line 142, in run
    ret = self.run_oldstyle()
  File "/usr/lib/python2.7/site-packages/salt/cli/cp.py", line 165, in run_oldstyle
    return local.cmd(*args)
  File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 741, in cmd
    **kwargs):
  File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 1603, in get_cli_event_returns
    **kwargs
  File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 1184, in get_iter_returns
    for raw in ret_iter:
  File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 1109, in get_returns_no_block
    no_block=True, auto_reconnect=self.auto_reconnect)
  File "/usr/lib/python2.7/site-packages/salt/utils/event.py", line 642, in get_event
    ret = self._get_event(wait, tag, match_func, no_block)
  File "/usr/lib/python2.7/site-packages/salt/utils/event.py", line 544, in _get_event
    mtag, data = self.unpack(raw, self.serial)
  File "/usr/lib/python2.7/site-packages/salt/utils/event.py", line 435, in unpack
    data = serial.loads(mdata, encoding='utf-8')
  File "/usr/lib/python2.7/site-packages/salt/payload.py", line 144, in loads
    ret = msgpack.loads(msg, use_list=True, ext_hook=ext_type_decoder, encoding=encoding)
  File "msgpack/_unpacker.pyx", line 138, in msgpack._unpacker.unpackb (msgpack/_unpacker.cpp:138)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x8b in position 1: invalid start byte
Traceback (most recent call last):
  File "/usr/bin/salt-cp", line 10, in <module>
    salt_cp()
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 387, in salt_cp
    client.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/cp.py", line 52, in run
    cp_.run()
  File "/usr/lib/python2.7/site-packages/salt/cli/cp.py", line 142, in run
    ret = self.run_oldstyle()
  File "/usr/lib/python2.7/site-packages/salt/cli/cp.py", line 165, in run_oldstyle
    return local.cmd(*args)
  File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 741, in cmd
    **kwargs):
  File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 1603, in get_cli_event_returns
    **kwargs
  File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 1184, in get_iter_returns
    for raw in ret_iter:
  File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 1109, in get_returns_no_block
    no_block=True, auto_reconnect=self.auto_reconnect)
  File "/usr/lib/python2.7/site-packages/salt/utils/event.py", line 642, in get_event
    ret = self._get_event(wait, tag, match_func, no_block)
  File "/usr/lib/python2.7/site-packages/salt/utils/event.py", line 544, in _get_event
    mtag, data = self.unpack(raw, self.serial)
  File "/usr/lib/python2.7/site-packages/salt/utils/event.py", line 435, in unpack
    data = serial.loads(mdata, encoding='utf-8')
  File "/usr/lib/python2.7/site-packages/salt/payload.py", line 144, in loads
    ret = msgpack.loads(msg, use_list=True, ext_hook=ext_type_decoder, encoding=encoding)
  File "msgpack/_unpacker.pyx", line 138, in msgpack._unpacker.unpackb (msgpack/_unpacker.cpp:138)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x8b in position 1: invalid start byte

你期待的结果是什么?实际看到的错误信息又是什么?

不知道这是什么情况。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文