salt icon indicating copy to clipboard operation
salt copied to clipboard

Add timeout as a state requisite

Open layer3switch opened this issue 8 years ago • 5 comments

Description of Issue/Question

Tornado 4.2.1 httputil.py requires matching 3 tuples for http response (version, code and reason). When host (most java http server) responses with only "HTTP/1.1 200" in the header, file.managed hangs indefinitely even with "retry" option.

Salt debug log shows following

[INFO    ] Running state [/var/lib/jenkins/swarm-client-3.7.jar] at time 21:44:50.548863
[INFO    ] Executing state file.managed for [/var/lib/jenkins/swarm-client-3.7.jar]
[DEBUG   ] Requesting URL http://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/swarm-client/3.7/swarm-client-3.7.jar using GET method
[INFO    ] Malformed HTTP message from None: Error parsing response start line

Setup

using below salt pillar data...

    swarm_client:
      app_name: 'swarm-client'
      download_url: 'https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/swarm-client'
      version: '3.7'
      source_hash: '79ac8792c4e9436249c0d9d003fb0cedc06bc076'

using state below

{% set url = p.get('download_url') %}
{% set app = p.get('app_name') %}
{% set version = p.get('version') %}
{% set artifact_sha1sum = p.get('source_hash') %}
{% set source_url = url ~ '/' ~ version %}
{% set artifact = app ~ '-' ~ version ~ '.jar' %}

jenkins_swarm_client:
  file.managed:
    - name: {{ jenkins.home }}/{{ artifact }}
    - source: {{ source_url }}/{{ artifact }}
    - source_hash: {{ artifact_sha1sum }}
    - user: {{ jenkins.user }}
    - group: {{ jenkins.group }}
    - mode: 644
    - retry:
      - attempts: 2
      - interval: 5

Steps to Reproduce Issue

file.managed state to pull file from any HTTP file server producing "HTTP/1.1 200" without "OK" reason in response header.

Versions Report

Salt Version:
           Salt: 2017.7.2

Dependency Versions:
           cffi: 1.6.0
       cherrypy: Not Installed
       dateutil: 1.5
      docker-py: Not Installed
          gitdb: 0.6.4
      gitpython: 1.0.1
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: 0.24.6
        libnacl: Not Installed
       M2Crypto: 0.21.1
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   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: 0.9.0
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4

System Versions:
           dist: centos 7.4.1708 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-693.5.2.el7.x86_64
         system: Linux
        version: CentOS Linux 7.4.1708 Core

layer3switch avatar Dec 28 '17 22:12 layer3switch

This seems like it is a bug in the tornado library.

You can set the http backend to requests, and this case is handled for me.

I would suggest opening this issue on tornado, since we are just using it directly.

https://github.com/tornadoweb/tornado

Thanks, Daniel

gtmanfred avatar Dec 29 '17 15:12 gtmanfred

I agree that this is upstream bug, and also agree that changing backend to urllib2 address this issue. However other states are utilizing Tornado httputil and will break in my case due to the fact that Tornado is the default.

The biggest concern I have is that a default setting can indefinitely hang a state due to lack of fail status. Is there a method or an option to terminate source from hanging file.managed state regardless of http backend library?

layer3switch avatar Dec 29 '17 17:12 layer3switch

There is not, but we should totally include a way to set a timeout on a specific state so that it can be killed if it hangs.

I have updated the title to better describe that, and marked this as a feature request.

Thanks, Daniel

gtmanfred avatar Dec 29 '17 17:12 gtmanfred

Thank you, Daniel.

I've reported the bug in tornado upstream with a patch as pull request. However I doubt this will make any difference in downstream mainly due to lack of backporting python module libraries in many distribution.

Thanks again, Daniel.

layer3switch avatar Dec 29 '17 19:12 layer3switch

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] avatar Apr 23 '19 19:04 stale[bot]