{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3185","repository_url":"https://api.github.com/repos/ansible/ansible-modules-core","labels_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3185/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3185/comments","events_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3185/events","html_url":"https://github.com/ansible/ansible-modules-core/issues/3185","id":138499366,"number":3185,"title":"exclude_hosts are not working for wait_for/drained","user":{"login":"eddwardo","id":1431465,"avatar_url":"https://avatars.githubusercontent.com/u/1431465?v=3","gravatar_id":"","url":"https://api.github.com/users/eddwardo","html_url":"https://github.com/eddwardo","followers_url":"https://api.github.com/users/eddwardo/followers","following_url":"https://api.github.com/users/eddwardo/following{/other_user}","gists_url":"https://api.github.com/users/eddwardo/gists{/gist_id}","starred_url":"https://api.github.com/users/eddwardo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eddwardo/subscriptions","organizations_url":"https://api.github.com/users/eddwardo/orgs","repos_url":"https://api.github.com/users/eddwardo/repos","events_url":"https://api.github.com/users/eddwardo/events{/privacy}","received_events_url":"https://api.github.com/users/eddwardo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/affects_2.0","name":"affects_2.0","color":"5319e7"},{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/bug_report","name":"bug_report","color":"fbca04"},{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/needs_info","name":"needs_info","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-03-04T15:14:52Z","updated_at":"2016-10-06T14:57:52Z","closed_at":null,"body":"##### Issue Type:\r\n\r\n - Bug Report\r\n\r\n##### Plugin Name:\r\n\r\nwait_for\r\n\r\n##### Ansible Version:\r\n\r\n```\r\nansible 2.0.0.2\r\n```\r\n\r\n##### Ansible Configuration:\r\n\r\n```\r\n[defaults]\r\n\r\n# Don't use cowsay\r\nnocows = 1\r\n\r\n# We like parallel\r\nforks = 100\r\n\r\nhost_key_checking=False\r\n```\r\n\r\n##### Environment:\r\n\r\nLinux->Linux\r\n\r\n##### Summary:\r\n\r\n`Wait_for` ignores `exclude_hosts` when using it for `drained` connections  \r\n\r\n##### Steps To Reproduce:\r\n\r\nwait_for definition:\r\n\r\n```\r\n 8 - name: \"Wait for connections to drain\"\r\n 9   wait_for: port={{app_port}} timeout=20 state=drained exclude_hosts=127.0.0.1\r\n```\r\n\r\nI copied generated script in tmp, and put debugger there.\r\n\r\n```\r\n    def get_active_connections_count(self):\r\n        active_connections = 0\r\n        f = open(self.source_file[self.family])\r\n        for tcp_connection in f.readlines():\r\n            tcp_connection = tcp_connection.strip().split()\r\n            if tcp_connection[self.local_address_field] == 'local_address':\r\n                continue\r\n            if tcp_connection[self.connection_state_field] not in self.connection_states:\r\n                continue\r\n            (local_ip, local_port) = tcp_connection[self.local_address_field].split(':')\r\n            if self.port == local_port and self.ip in [self.match_all_ips[self.family], local_ip]:\r\n                 (remote_ip, remote_port) = tcp_connection[self.remote_address_field].split(':')\r\n                 if remote_ip not in self.exclude_ips:\r\n                     import pdb; pdb.set_trace()\r\n                     active_connections += 1\r\n        f.close()\r\n        return active_connections\r\n```\r\n\r\nQuick debug session:\r\n\r\n```\r\n(Pdb) remote_ip in self.exclude_ips\r\nFalse\r\n(Pdb) remote_ip\r\n'0100007F'\r\n(Pdb) self.exclude_ips\r\n[(2, '0100007F')]\r\n(Pdb)\r\n```\r\n\r\n ```\r\n250                      if remote_ip not in self.exclude_ips:\r\n251                          import pdb; pdb.set_trace()\r\n252  ->                      active_connections += 1\r\n```\r\n\r\nIn short, the ` if remote_ip not in self.exclude_ips` will always return False because `remote_ip` is a string and items in `self.exclude_ips` are tuples.\r\n\r\n##### Expected Results:\r\n\r\nIgnore localhost connection when counting drained connections\r\n\r\n##### Actual Results:\r\n\r\n`wait_for` times out, because it keep adding connections that should be ignored.\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/comments/251988598","html_url":"https://github.com/ansible/ansible-modules-core/issues/3185#issuecomment-251988598","issue_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3185","id":251988598,"user":{"login":"ansibot","id":6585283,"avatar_url":"https://avatars.githubusercontent.com/u/6585283?v=3","gravatar_id":"","url":"https://api.github.com/users/ansibot","html_url":"https://github.com/ansibot","followers_url":"https://api.github.com/users/ansibot/followers","following_url":"https://api.github.com/users/ansibot/following{/other_user}","gists_url":"https://api.github.com/users/ansibot/gists{/gist_id}","starred_url":"https://api.github.com/users/ansibot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansibot/subscriptions","organizations_url":"https://api.github.com/users/ansibot/orgs","repos_url":"https://api.github.com/users/ansibot/repos","events_url":"https://api.github.com/users/ansibot/events{/privacy}","received_events_url":"https://api.github.com/users/ansibot/received_events","type":"User","site_admin":false},"created_at":"2016-10-06T14:57:51Z","updated_at":"2016-10-06T14:57:51Z","body":"@eddwardo ping, this issue is still waiting on your feedback. We will close the issue if you do not respond.\n[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)\n<!--- boilerplate: issue_closure --->"}}
{"actor":{"display_login":"ansibot"}}