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

Proxmox LXC Create Container runs into timeout #6843

Open
1 task done
miccico opened this issue Jul 3, 2023 · 8 comments
Open
1 task done

Proxmox LXC Create Container runs into timeout #6843

miccico opened this issue Jul 3, 2023 · 8 comments
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type)

Comments

@miccico
Copy link
Contributor

miccico commented Jul 3, 2023

Summary

When running against a rather loaded proxmox cluster i sometimes encounter the following issue:

fatal: [vihwaf03]: FAILED! => {"changed": false, "msg": "Pre-creation checks of lxc VM 893 failed with exception: HTTPSConnectionPool(host='xxxxxxxxxxxxx', port=8006): Read timed out. (read timeout=5)"}

After some debugging i noticed that proxmoxer internally uses a 5 second timeout for the operations which seems to be insufficient for the creation under some load conditions. After investigating the code I saw that the timeout value provided to the ansible task is not handed over to the proxmoxer class. I would request to pass along the timeout (or a share of the timeout) provided to the ansible task to the proxmoxer class.

Issue Type

Bug Report

Component Name

proxmox

Ansible Version

$ ansible --version
ansible [core 2.14.4]
  config file = /opt/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

# /root/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 7.1.0

Configuration

$ ansible-config dump --only-changed

CONFIG_FILE() = /opt/ansible/ansible.cfg
DEFAULT_HOST_LIST(/opt/ansible/ansible.cfg) = ['/opt/ansible/inventory.yml']

OS / Environment

Debian 11.7 running in LXC container

Steps to Reproduce

Have a very sad and slow proxmox cluster and try to create a container while having bad luck

- name: Create container
  throttle: 1
  proxmox:
    vmid: "{{vmid}}"
    node: "{{ proxmox_node if proxmox_node is defined else omit}}"
    api_host: "{{ proxmox_api_host }}"
    api_user: "{{ proxmox_api_user }}"
    api_password: "{{ proxmox_api_password }}"
    password: "{{rootpassword}}"
    hostname: "{{inventory_hostname}}"
    ostemplate: "{{lxc_template}}"
    unprivileged: "{{ lxc_unprivileged if lxc_unprivileged is defined else true}}"
    pool: AnsibleManaged
    description: Created by ansible playbook
    tags: ansible
    #mounts: '{"mp0":"local:8,mp=/mnt/test/"}'
    netif:
      net0: "{{ lookup('template', 'netif0.j2') if lxc_net0_ip is defined else omit }}"
      net1: "{{ lookup('template', 'netif1.j2') if lxc_net1_ip is defined else omit }}"
      net2: "{{ lookup('template', 'netif2.j2') if lxc_net2_ip is defined else omit }}"
    cores: "{{ lxc_cores if lxc_cores is defined else '2'}}"
    #order: "{{ lxc_startuporder if lxc_startuporder is defined else omit}}"
    cpus: "{{ lxc_cpus if lxc_cpus is defined else omit}}"
    storage: "{{ lxc_storage if lxc_storage is defined else 'local'}}"
    disk: "{{ lxc_storage if lxc_storage is defined else 'local'}}:{{ lxc_storage_size if lxc_storage_size is defined else '2'}}"
    onboot: yes
    memory: "{{ lxc_memory if lxc_memory is defined else '128'}}"
    swap: "{{ lxc_swap if lxc_swap is defined else '128'}}"
    pubkey: '{{ lookup("ansible.builtin.file", "~/.ssh/id_rsa.pub") }}'
    #state: started
    timeout: 500

Expected Results

Execution of the creation without error

Actual Results

fatal: [vihwaf03]: FAILED! => {"changed": false, "msg": "Pre-creation checks of lxc VM 893 failed with exception: HTTPSConnectionPool(host='xxxxxxxxxxxxx', port=8006): Read timed out. (read timeout=5)"}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

  • plugins/modules/proxmox

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
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module plugins plugin (any type) labels Jul 3, 2023
@russoz
Copy link
Collaborator

russoz commented Jul 6, 2023

Hi @miccico , thanks for the bug report!

I am working on a PR here, and a coupla disclaimers:

  • The code that interacts with proxmoxer is shared amongst all the proxmox modules
  • Not all those modules have a timeout parameter, the ones that do are: proxmox_disk, proxmox_kvm, proxmox_snap, proxmox_template, proxmox

@ansibullbot
Copy link
Collaborator

@krauthosting
Copy link

@l00ptr Could you review this? This looks good to us, just changing the timeout to a longer value through module args shouldn't have any adverse effect? Checking the Proxmoxer source code mentioned in the original issue shows that it already has a default timeout of 5s set for the HTTP backend, and the parameter is ignored for other backends: https://github.com/proxmoxer/proxmoxer/blob/d7419ab03628aa7cbcf24e90f981446996b91100/proxmoxer/backends/https.py#L261

@russoz What you mean by polling the API here? At least in @UnderGreens example, the new timeout should only affect the duration of the actual API calls itself (such as self.api_task_ok), but leaves the overall polling mechanism intact? Please add still a changelog fragment and merge, so we can move the proxmox modules to the new community.proxmox asap 🤗

@russoz
Copy link
Collaborator

russoz commented Feb 26, 2024

Hi @krauthosting , that was quite a while ago and I have not returned to this issue ever since. I think it is safe to ignore my comments from those days and move forward to a new solution.

@krauthosting
Copy link

krauthosting commented Feb 27, 2024

@russoz Thanks for confirming and please reopen in the community.proxmox collection 🤗
@felixfontein Can you please close this issue?

@felixfontein
Copy link
Collaborator

@krauthosting why close + reopen instead of transfer the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants