Skip to content
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

hcloud_load_balancer_info don't return status #467

Open
EHEX-schildt opened this issue Feb 20, 2024 · 7 comments
Open

hcloud_load_balancer_info don't return status #467

EHEX-schildt opened this issue Feb 20, 2024 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@EHEX-schildt
Copy link

EHEX-schildt commented Feb 20, 2024

SUMMARY

I would like to get the HEALTH STATUS of a loadbalencer to ensure that everything is fine before i continue my ansible run.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

hetzner.hcloud.load_balancer_info

ANSIBLE VERSION
ansible [core 2.16.3]
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/home/.../git/ext-infra/venv/bin/python3)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
Collection     Version
-------------- -------
hetzner.hcloud 2.4.1
STEPS TO REPRODUCE
---
- name: Get LB Status
  hosts: localhost
  tags: lb
  tasks:
    - name: Create test-lb
      hetzner.hcloud.load_balancer:
        name: test-lb
        load_balancer_type: lb11
        location: nbg1
        api_token: "{{ hcloud_api_token }}"
    - name: Add service to test-lb
      hetzner.hcloud.load_balancer_service:
        load_balancer: test-lb
        protocol: tcp
        listen_port: 80
        destination_port: 80
        proxyprotocol: yes
        api_token: "{{ hcloud_api_token }}"
    - name: Add Balancer target
      hetzner.hcloud.load_balancer_target:
        type: label_selector
        load_balancer: test-lb
        label_selector: pool=test-lb
        api_token: "{{ hcloud_api_token }}"
    - name: Gather hcloud load_balancer infos
      hetzner.hcloud.load_balancer_info:
        name: test-lb
        api_token: "{{ hcloud_api_token }}"
      register: output
    - name: Print the gathered infos
      ansible.builtin.debug:
        var: output.hcloud_load_balancer_info
EXPECTED RESULTS

some sort of status like "running" in output.hcloud_load_balancer_info
https://docs.ansible.com/ansible/latest/collections/hetzner/hcloud/load_balancer_info_module.html#return-hcloud_load_balancer_info/status

ACTUAL RESULTS
ok: [localhost] => {
    "output.hcloud_load_balancer_info": [
        {
            "delete_protection": false,
            "disable_public_interface": false,
            "id": "1706869",
            "ipv4_address": "some-ipv4",
            "ipv6_address": "some-ipv6",
            "labels": {},
            "load_balancer_type": "lb11",
            "location": "nbg1",
            "name": "test-lb",
            "private_ipv4_address": null,
            "services": [
                {
                    "destination_port": 80,
                    "health_check": {
                        "interval": 15,
                        "port": 80,
                        "protocol": "tcp",
                        "retries": 3,
                        "timeout": 10
                    },
                    "http": null,
                    "listen_port": 80,
                    "protocol": "tcp",
                    "proxyprotocol": true
                }
            ],
            "targets": [
                {
                    "label_selector": "pool=test-lb",
                    "type": "label_selector",
                    "use_private_ip": false
                }
            ]
        }
    ]
}

@jooola
Copy link
Collaborator

jooola commented Feb 29, 2024

Hi,
The returned status from the documentation shouldn't exist, I will remove it from the docs. We could compute our own value for this status field, but I am not sure if this is ideal.

There is a health_status object for the targets https://docs.ansible.com/ansible/latest/collections/hetzner/hcloud/load_balancer_info_module.html#return-hcloud_load_balancer_info/targets/health_status, you may use this value to check the status of your load balancer.
Note that:

  • the health status is only present for IP or server targets.
  • the health status might time some time to be returned by the API.

See https://docs.hetzner.cloud/#load-balancers-get-a-load-balancer

@jooola
Copy link
Collaborator

jooola commented Mar 1, 2024

in my example output there is also no "health_status object for the targets".

This is because the target is of type label_selector, as stated above, the health status is only present on IP or server target types. You can find the documentation for the health status field here https://docs.hetzner.cloud/#load-balancers-get-a-load-balancer

@EHEX-schildt
Copy link
Author

Thanks a i realized this a few minutes before and delete my comment ;-)

@EHEX-schildt
Copy link
Author

EHEX-schildt commented Mar 1, 2024

Ok so there is no way to verify the overall Health of a loadbalencer with label_selector targets?

@jooola
Copy link
Collaborator

jooola commented Mar 1, 2024

I just tested this myself, and the "resolved" targets from the label_selector target, do have a health status. This is not clear in the documentation, I'll try to improve this, and I'll get back to you with a solution.

The API response looks like the following:

{
  "targets": [
    {
      "type": "label_selector",
      "use_private_ip": false,
      "label_selector": {
        "selector": "test=ok"
      },
      "targets": [
        {
          "type": "server",
          "server": {
            "id": 43962499
          },
          "health_status": [
            {
              "listen_port": 80,
              "status": "unhealthy"
            }
          ],
          "use_private_ip": false
        }
      ]
    }
  ]
}

@jooola jooola added the bug Something isn't working label Mar 1, 2024
@jooola jooola self-assigned this Mar 1, 2024
Copy link

This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs.

@github-actions github-actions bot added the stale label May 31, 2024
@jooola jooola removed the stale label May 31, 2024
@EHEX-schildt
Copy link
Author

not stale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants