saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.18k stars 5.48k forks source link

[BUG] the carbon returner has a type error #61284

Open kresike opened 2 years ago

kresike commented 2 years ago

Description There is a type error in the carbon returner, probably caused by the python2 -> python3 migration that has not been handled yet.

Setup One needs to set up a carbon instance for the carbon returner and schedule a munin plugin to be run by the salt-minion scheduler to run any munin plugin on the machine in question and return data using the carbon returner.

Please be as specific as possible and give set-up details.

Steps to Reproduce the behavior Add the following to minion.conf

carbon.host: 10.0.0.1
carbon.port: 2003
carbon.mode: text
schedule:
    munin:
        function: munin.run
        args:
            - cpu
        seconds: 60
        returner: carbon

Restart the salt minion and wait for the scheduler to run. In the logs the error below appears:

2021-11-23 11:42:33,024 [salt.utils.schedule:875 ][ERROR   ][4032195] Unhandled exception running munin.run
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/utils/schedule.py", line 866, in handle_func
    self.returners[ret_str](ret)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1201, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1216, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/returners/carbon_return.py", line 297, in returner
    _send(saltdata, metric_base, opts)
  File "/usr/lib/python3/dist-packages/salt/returners/carbon_return.py", line 255, in _send
    sent_bytes = sock.send(data[total_sent_bytes:])
TypeError: a bytes-like object is required, not 'str'

Expected behavior The data should be sent to the graphite instance.

Screenshots None.

Versions Report

Salt Version:
          Salt: 3004

Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.11.3
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.0
  msgpack-pure: Not Installed
  mysql-python: 1.4.4
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: 3.9.7
        pygit2: Not Installed
        Python: 3.9.2 (default, Feb 28 2021, 17:03:44)
  python-gnupg: Not Installed
        PyYAML: 5.3.1
         PyZMQ: 20.0.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: debian 11 bullseye
        locale: utf-8
       machine: x86_64
       release: 5.10.0-8-amd64
        system: Linux
       version: Debian GNU/Linux 11 bullseye

Additional context I will post a pull request with a very simple fix to this problem.

welcome[bot] commented 2 years ago

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey. Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

garethgreenaway commented 2 years ago

@kresike Thanks for the report. It appears that your open PR is against your own fork of Salt, did you mean to open that against the Salt repo?

kresike commented 2 years ago

Oops, sorry abou that. Let me fix that.

kresike commented 2 years ago

@garethgreenaway I've created a new one, this one looks better. Sorry about that!