community.general icon indicating copy to clipboard operation
community.general copied to clipboard

Module haproxy times out instead of setting HAProxy backends into DRAIN mode followed by MAINT when the Backend is down / unreachable

Open Dcosmas opened this issue 1 year ago • 4 comments

Summary

Hi, I'm sorry @RayJin2000 but state is not a String but a tuple of map :( so the issue https://github.com/ansible-collections/community.general/issues/8092 has to be reopen I think.

if self.wait and not (wait_for_status == "DRAIN" and state == "DOWN"):

have to be

if self.wait and not (wait_for_status == "DRAIN" and state[0]['status'] == "DOWN"):

Thank you for your time and consideration.

Issue Type

Bug Report

Component Name

haproxy

Ansible Version

$ ansible --version
ansible [core 2.17.1]
  config file = None
  configured module search path = ['/home/dcosmas/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/dcosmas/.virtualenvs/ansible-10.1/lib/python3.10/site-packages/ansible
  ansible collection location = /home/dcosmas/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/dcosmas/.virtualenvs/ansible-10.1/bin/ansible
  python version = 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0] (/home/dcosmas/.virtualenvs/ansible-10.1/bin/python)
  jinja version = 3.1.4
  libyaml = True


Community.general Version

$ ansible-galaxy collection list community.general
Collection        Version
----------------- -------
community.general 9.1.0

Configuration

$ ansible-config dump --only-changed
CONFIG_FILE() = None
EDITOR(env: EDITOR) = /bin/nano

OS / Environment

Debian 11 & 12

Steps to Reproduce

# the backend needs to be DOWN
    - name: Set backend state
      community.general.haproxy:
        state: disabled
        host: "{{ _host }}"
        socket: /tmp/haproxy.admin.sock
        wait: true
        drain: true
        wait_interval: 5
        wait_retries: 25
      become: true

Expected Results

The expected behavior would be to either directly fail or bypass the DRAIN mode and enter MAINT immediately.

Actual Results

server bk_web/front not status 'DRAIN' after 10 retries. Aborting.State: ({'status': 'DOWN', 'weight': '1', 'scur': '0'},)

Code of Conduct

  • [X] I agree to follow the Ansible Code of Conduct

Dcosmas avatar Oct 11 '24 13:10 Dcosmas

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot avatar Oct 11 '24 13:10 ansibullbot

cc @Normo @ravibhure click here for bot help

ansibullbot avatar Oct 11 '24 13:10 ansibullbot

For reference, the old PR was #8100.

felixfontein avatar Oct 11 '24 19:10 felixfontein

(Also state can also be None, so simply using state[0]['status'] won't work either. The condition needs to be slightly more complex.)

felixfontein avatar Oct 11 '24 19:10 felixfontein