当使用eventlet运行芹菜时,Fabric失败,名称查找失败



我有一个芹菜任务,使用fabric在远程机器上运行sudo命令:

@app.task(soft_time_limit=600)
def run_puppet_agent(hostname):
    try:
        fabric_client = Fabric(hostname)
        result = fabric_client.run_command('puppet agent -t', True, True)
        if result.return_code == 0 or result.return_code == 2:
                return True, 'Puppet agent run successfully'
        else:
            raise Exception('Command %s run failed with a non zero or non-2 error code, '
                            '0 and 2 are status codes for successful puppet runs, returned     code %s'
                            % ('sudo puppet agent -t', result.return_code))
    except SoftTimeLimitExceeded:
        raise Exception('Puppet agent run took more than 600 seconds')
    except Exception as e:
        #run_puppet_agent.retry(args=[hostname], countdown=20)
        LOG.info('')
        raise Exception('Puppet agent failed with error message %s' % e.message)

如果我运行芹菜工人:

celery -A phantom.celery.manage worker --loglevel=info

它工作得很好!但是当我使用eventlet运行worker时:

celery -A phantom.celery.manage worker --loglevel=info -P eventlet -c 15

它非常糟糕,给了我这个例外:

[WARNING/MainProcess] File     "/Users/uruddarraju/Phantom/phantom/tasks/fabric_tasks.py", line 19, in run_puppet_agent
[WARNING/MainProcess] result = fabric_client.run_command('puppet agent -t', True, True)
[WARNING/MainProcess] File "/Users/uruddarraju/Phantom/phantom/util/fabric/fabric_util.py", line 43, in run_command
[WARNING/MainProcess] return sudo(command, quiet=False)
[WARNING/MainProcess] File "/Library/Python/2.7/site-packages/fabric/network.py", line 639, in host_prompting_wrapper
[WARNING/MainProcess] return func(*args, **kwargs)
[WARNING/MainProcess] File "/Library/Python/2.7/site-packages/fabric/operations.py", line 1095, in sudo
[stderr=stderr, timeout=timeout, shell_escape=shell_escape,
[WARNING/MainProcess] File "/Library/Python/2.7/site-packages/fabric/operations.py", line 909, in _run_command
[WARNING/MainProcess] channel=default_channel(), command=wrapped_command, pty=pty,
[WARNING/MainProcess] File "/Library/Python/2.7/site-packages/fabric/state.py", line 390, in default_channel
[WARNING/MainProcess] chan = _open_session()
[WARNING/MainProcess] File "/Library/Python/2.7/site-packages/fabric/state.py", line 382, in _open_session
[WARNING/MainProcess] return connections[env.host_string].get_transport().open_session()
[WARNING/MainProcess] File "/Library/Python/2.7/site-packages/fabric/network.py", line 151, in __getitem__
[WARNING/MainProcess] self.connect(key)
[WARNING/MainProcess] File "/Library/Python/2.7/site-packages/fabric/network.py", line 143, in connect
[WARNING/MainProcess] self[key] = connect(user, host, port, cache=self)
[WARNING/MainProcess] File "/Library/Python/2.7/site-packages/fabric/network.py", line 533, in connect
[WARNING/MainProcess] raise NetworkError('Name lookup failed for %s' % host, e)
[WARNING/MainProcess] NetworkError: Name lookup failed for <hostname>

警告/MainProcess]没有

仅供参考:我有其他任务,有不同的HTTP API调用,因此,虽然eventlet会有所帮助,但在这种情况下不为我工作

我用gevent代替了work…解决了我的问题!!谢谢你的帮助

相关内容

  • 没有找到相关文章

最新更新