cvk98 / Proxmox-load-balancer

Designed to constantly maintain the Proxmox cluster in balance
GNU General Public License v3.0
186 stars 22 forks source link

no ['master_node'] value - script error #21

Open Tradeforlife opened 9 months ago

Tradeforlife commented 9 months ago

As of 1/03/2024 Proxmox hosts fully patched using a ubuntu 23.x LXC within a python env and the current build of Proxmox-load-balancer of 1/03/2024. when I run the program after updating the config file with correct info I get.

(.env) root@prox-lb:/opt/Proxmox-load-balancer# python plb.py 
INFO | START ***Load-balancer!***
Traceback (most recent call last):
  File "/opt/Proxmox-load-balancer/plb.py", line 496, in <module>
    main()
  File "/opt/Proxmox-load-balancer/plb.py", line 466, in main
    cluster = Cluster(server_url)
              ^^^^^^^^^^^^^^^^^^^
  File "/opt/Proxmox-load-balancer/plb.py", line 96, in __init__
    self.cl_nodes: dict = self.cluster_hosts()  # All cluster nodes
                          ^^^^^^^^^^^^^^^^^^^^
  File "/opt/Proxmox-load-balancer/plb.py", line 169, in cluster_hosts
    self.master_node = rr.json()['data']['manager_status']['master_node']
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'master_node'

I edit the plb.py to show the output of the rr.json() within the cluster_hosts(self) function and it showed the below output. there is no master_node key. I'm not sure if it's not required anymore of I have something changed in my cluster.. either way it's not working.

{'data': {'manager_status': {'node_status': {}}, 'quorum': {'quorate': '1', 'node': 'pve-quorum'}}}

Cluster Information

root@pve-quorum:~# pvecm status
Cluster information
-------------------
Name:             cluster1
Config Version:   12
Transport:        knet
Secure auth:      on

Quorum information
------------------
Date:             Fri Mar  1 13:31:53 2024
Quorum provider:  corosync_votequorum
Nodes:            4
Node ID:          0x00000002
Ring ID:          1.848
Quorate:          Yes

Votequorum information
----------------------
Expected votes:   4
Highest expected: 4
Total votes:      4
Quorum:           3  
Flags:            Quorate 

Membership information
----------------------
    Nodeid      Votes    Qdevice Name
0x00000001          1  NA,NV,NMW 192.168.10.11
0x00000002          1         NR 192.168.10.30 (local)
0x00000003          1         NR 192.168.10.10
0x00000004          1         NR 192.168.10.12
0x00000000          0            Qdevice (votes 0)
root@pve-quorum:~# 
Tradeforlife commented 9 months ago

NOTE : I just commented out

self.master_node = rr.json()['data']['manager_status']['master_node']

any it seems to be running, not sure if this is required anywhere else.

cvk98 commented 9 months ago

This is required if the script is installed on all nodes. In this case, only 1 should decide how to balance. And thus the HA master is selected. If you have 1 instance, this mechanism is not needed at all.

cvk98 commented 9 months ago

Without HA, there is no master node in the cluster.

Tradeforlife commented 9 months ago

I uncommented the line and enabled HA and now it's working as expected, thanks.