New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy + file.managed => Comment: Failed to cache xxx invalid arguments to setopt #46896

Closed
Poil opened this Issue Apr 5, 2018 · 4 comments

Comments

Projects
None yet
6 participants
@Poil

Poil commented Apr 5, 2018

Description of Issue/Question

Setup

  • salt configuration
    My minion have this salt configuration (it's running on the same host as the master, I'm evaluating SaltStack)
    master: salt.mydomain
    proxy_host: xx.xx.xx.xx
    proxy_port: 3128

  • OS:
    EL7 x86_64
    Salt RPM version : 2018.3.0-1.el7.noarch

Steps to Reproduce Issue

Configure a proxy on you minion and add a file.managed source from http.
Restart the minion. Apply change
Error (here with epel-formula from your repository)

          ID: install_pubkey_epel
    Function: file.managed
        Name: /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
      Result: False
     Comment: Failed to cache https://getfedora.org/static/352C64E5.txt: invalid arguments to setopt
     Started: 17:40:52.580545
    Duration: 5.308 ms
     Changes:   

When I do not configure a proxy I have a timeout (this is normal, no direct access to Internet)

Versions Report

Salt Version:
           Salt: 2018.3.0
 
Dependency Versions:
           cffi: 1.6.0
       cherrypy: unknown
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: 0.24.6
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: 0.24.2
         Python: 2.7.5 (default, Aug  4 2017, 00:39:18)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4
@lomeroe

This comment has been minimized.

Contributor

lomeroe commented Apr 5, 2018

Seems to be related to the tornado backend, Using one of the other backends, makes it work (for me):

backend: urrlib2

or

backend: requests

The version of tornado is the same between my 2016.11/2017.7/2018.3 minions (4.2.1). I also tried upgrading tornado to 5.0.1 with pip.

@PabloLemos

This comment has been minimized.

PabloLemos commented Jun 7, 2018

I have the same problem with the archive.extracted and tornado backend:

archive.extracted: - name: {{ postgres['pg_base'] }}-{{ postgres['version'] }} - source: https://get.enterprisedb.com/postgresql/postgresql-{{ postgres['version'] }}-1-linux-x64-binaries.tar.gz - skip_verify: True - if_missing: {{ postgres['pg_datos'] }} - user: postgres - group: postgres - enforce_ownership_on: {{ postgres['pg_base'] }}-{{ postgres['version'] }} - enforce_toplevel: False - keep_source: False - trim_output: True - options: --strip-components=1

the minion configuration is:

proxy_host: proxy_url.es
proxy_port: 8080

@pacaj2am

This comment has been minimized.

pacaj2am commented Jul 9, 2018

Hi,

Did some testing. Python3 salt-minon works fine with tornado (it is using different version of python34-tornado from epel, not from saltstack repo).

python-tornado.x86_64           4.2.1-3.el7                     @base

vs

python34-tornado.x86_64         4.4.2-1.el7                     @epel

we had the same issue here. The root cause might be in module http.query:

 salt-call -l all http.query https://github.com
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: p-lmgt-trd1-salt01.l
[TRACE   ] The required configuration section, 'fluent_handler', was not found tthe fluent logging handlers module.
[TRACE   ] None of the required configuration sections, 'logstash_udp_handler' a in the configuration. Not loading the Logstash logging handlers module.
[DEBUG   ] Configuration file path: /etc/salt/minion
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged
[DEBUG   ] Grains refresh requested. Refreshing grains.
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[TRACE   ] 'drill' could not be found in the following search path: '[u'/usr/loc, u'/bin', u'/usr/sbin', u'/usr/bin', u'/opt/puppetlabs/bin', u'/root/bin']'
[TRACE   ] 'esxcli' could not be found in the following search path: '[u'/usr/lo', u'/bin', u'/usr/sbin', u'/usr/bin', u'/opt/puppetlabs/bin', u'/root/bin']'
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Error loading grains.napalm: "napalm"" (/usr/lib/python2.7/site-packa loaded: NAPALM is not installed or not running in a (proxy) minion
[TRACE   ] Loading core.append_domain grain
[TRACE   ] Loading core.default_gateway grain
[TRACE   ] Loading core.dns grain
[TRACE   ] Loading core.get_machine_id grain
[TRACE   ] Loading core.get_master grain
[TRACE   ] Loading core.get_server_id grain
[TRACE   ] Loading core.hostname grain
[TRACE   ] Loading core.hwaddr_interfaces grain
[TRACE   ] Loading core.id_ grain
[TRACE   ] Loading core.ip4_interfaces grain
[TRACE   ] Loading core.ip6_interfaces grain
[TRACE   ] Loading core.ip_fqdn grain
[TRACE   ] Loading core.ip_interfaces grain
[TRACE   ] Loading core.linux_distribution grain
[TRACE   ] Loading core.locale_info grain
[TRACE   ] Loading core.os_data grain
[TRACE   ] Loading core.path grain
[TRACE   ] Loading core.pythonexecutable grain
[TRACE   ] Loading core.pythonpath grain
[TRACE   ] Loading core.pythonversion grain
[TRACE   ] Loading core.saltpath grain
[TRACE   ] Loading core.saltversion grain
[TRACE   ] Loading core.saltversioninfo grain
[TRACE   ] Loading core.zmqversion grain
[TRACE   ] Loading disks.disks grain
[TRACE   ] Device sda reports itself as an HDD
[TRACE   ] Device dm-0 reports itself as an HDD
[TRACE   ] Loading extra.config grain
[DEBUG   ] Loading static grains from /etc/salt/grains
[TRACE   ] Loading extra.shell grain
[TRACE   ] Loading mdadm.mdadm grain
[TRACE   ] Loading minion_process.grains grain
[TRACE   ] Loading opts.opts grain
[TRACE   ] Loading zfs.zfs grain
[TRACE   ] 'zfs-fuse' could not be found in the following search path: '[u'/usr/in', u'/bin', u'/usr/sbin', u'/usr/bin', u'/opt/puppetlabs/bin', u'/root/bin']'
[TRACE   ] 'zpool' could not be found in the following search path: '[u'/usr/loc, u'/bin', u'/usr/sbin', u'/usr/bin', u'/opt/puppetlabs/bin', u'/root/bin']'
[DEBUG   ] Connecting to master. Attempt 1 of 1
[DEBUG   ] Master URI: tcp://10.206.115.19:4506
[DEBUG   ] Initializing new AsyncAuth for (u'/etc/salt/pki/minion', u'p-lmgt-trd06.115.19:4506')
[DEBUG   ] Generated random reconnect delay between '1000ms' and '11000ms' (7101
[DEBUG   ] Setting zmq_reconnect_ivl to '7101ms'
[DEBUG   ] Setting zmq_reconnect_ivl_max to '11000ms'
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for (u'/etc/salt/pki/minion', u'tcp://10.206.115.19:4506', 'clear')
[DEBUG   ] Connecting the Minion to the Master URI (for the return server): tcp:
[DEBUG   ] Trying to connect to: tcp://10.206.115.19:4506
[TRACE   ] Inserted key into loop_instance_map id 140532047347936 for key (u'/ett01.li.jbvnett.no', u'tcp://10.206.115.19:4506', 'clear') and process 58931
[DEBUG   ] salt.crypt.get_rsa_pub_key: Loading public key
[DEBUG   ] Decrypting the current master AES key
[DEBUG   ] salt.crypt.get_rsa_key: Loading private key
[DEBUG   ] salt.crypt._get_key_with_evict: Loading private key
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG   ] salt.crypt.get_rsa_pub_key: Loading public key
[DEBUG   ] Connecting the Minion to the Master publish port, using the URI: tcp:
[DEBUG   ] salt.crypt.get_rsa_key: Loading private key
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG   ] Determining pillar cache
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for (u'/etc/salt/pki/minion', u'tcp://10.206.115.19:4506', u'aes')
[DEBUG   ] Initializing new AsyncAuth for (u'/etc/salt/pki/minion', u'p-lmgt-trd06.115.19:4506')
[DEBUG   ] Connecting the Minion to the Master URI (for the return server): tcp:
[DEBUG   ] Trying to connect to: tcp://10.206.115.19:4506
[TRACE   ] Inserted key into loop_instance_map id 140532013325272 for key (u'/ett01.li.jbvnett.no', u'tcp://10.206.115.19:4506', u'aes') and process 58931
[TRACE   ] ext_pillar_extra_data = {}
[DEBUG   ] salt.crypt.get_rsa_key: Loading private key
[DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded http.query
[DEBUG   ] Requesting URL https://github.com using GET method
[DEBUG   ] Using backend: tornado

Passed invalid arguments: invalid arguments to setopt.

Usage:

    Query a resource, and decode the return data

    .. versionadded:: 2015.5.0

    CLI Example:

    .. code-block:: bash

        salt '*' http.query http://somelink.com/
        salt '*' http.query http://somelink.com/ method=POST             params=
        salt '*' http.query http://somelink.com/ method=POST             data='<

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 212, in call
    ret['return'] = func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/modules/http.py", line 38, in quer
    return salt.utils.http.query(url=url, opts=opts, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/utils/http.py", line 542, in query
    **req_kwargs
  File "/usr/lib64/python2.7/site-packages/tornado/httpclient.py", line 102, in
    self._async_client.fetch, request, **kwargs))
  File "/usr/lib64/python2.7/site-packages/tornado/ioloop.py", line 444, in run_
    return future_cell[0].result()
  File "/usr/lib64/python2.7/site-packages/tornado/concurrent.py", line 214, in
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
TypeError: invalid arguments to setopt
@lomeroe

This comment has been minimized.

Contributor

lomeroe commented Jul 23, 2018

the proxy_host option being passed as a unicode string seems to be the issue.

i.e. proxy_host=u'proxy' fails, but proxy_host='proxy' succeeds

Python3 doesn't have this distinction (IIRC), which would explain why it functions as expected there

This works for me (in salt/utils/http.py), with py2 -- haven't had a chance to test it w/py3 yet :

            result = download_client.fetch(
                url_full,
                method=method,
                headers=header_dict,
                auth_username=username,
                auth_password=password,
                body=data,
                validate_cert=verify_ssl,
                allow_nonstandard_methods=True,
                streaming_callback=streaming_callback,
                header_callback=header_callback,
                request_timeout=timeout,
                proxy_host=salt.utils.stringutils.to_str(proxy_host),
                proxy_port=proxy_port,
                proxy_username=proxy_username,
                proxy_password=proxy_password,
                raise_error=raise_error,
                decompress_response=False,
                **req_kwargs
            )

@rallytime rallytime closed this in d330567 Jul 27, 2018

cro added a commit to cro/salt that referenced this issue Jul 27, 2018

pass proxy_user, proxy_password, proxy_host, and ca_certs through
salt.utils.stringutils.to_str()

tornado in py2 requires str not unicode strings

fixes saltstack#46896
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment