cvk98 / Proxmox-load-balancer

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

rr.json KeyError: 'master_node' #5

Closed BerKer999 closed 2 years ago

BerKer999 commented 2 years ago

is rr.json missing?

Regards,

root@pve:~/Proxmox-load-balancer# ./plb.py INFO | START Load-balancer! DEBUG | Authorization attempt... DEBUG | Successful authentication. Response code: 200 DEBUG | init when creating a Cluster object DEBUG | Starting Cluster.cluster_name DEBUG | Information about the cluster name has been received. Response code: 200 DEBUG | Launching Cluster.cluster_items DEBUG | Attempt to get information about the cluster... DEBUG | Information about the cluster has been received. Response code: 200 DEBUG | Launching Cluster.cluster_hosts DEBUG | Attempt to get information about the cluster HA manager... DEBUG | Information about the cluster HA Manager has been received. Response code: 200 Traceback (most recent call last): File "/root/Proxmox-load-balancer/./plb.py", line 468, in main() File "/root/Proxmox-load-balancer/./plb.py", line 439, in main cluster = Cluster(server_url) File "/root/Proxmox-load-balancer/./plb.py", line 84, in init self.cl_nodes: dict = self.cluster_hosts() # All cluster nodes File "/root/Proxmox-load-balancer/./plb.py", line 156, in cluster_hosts self.master_node = rr.json()['data']['manager_status']['master_node'] KeyError: 'master_node' root@pve:~/Proxmox-load-balancer# updatedb root@pve:~/Proxmox-load-balancer# locate rr.json root@pve:~/Proxmox-load-balancer#

cvk98 commented 2 years ago

I'll try to figure it out. Maybe Cylindrical (Mark Sanford) will help. This is his code.

cvk98 commented 2 years ago

Perhaps you are not using HA and the received json does not have the "master_node" key. I'll take a look later.

BerKer999 commented 2 years ago

HA setting was set to default (conditional) in Proxmox 7.2-4 not subscribe with 3 nodes

cvk98 commented 2 years ago

Please attach the following screenshots: image and image

BerKer999 commented 2 years ago

Now HA manager has been configured, Thanks pvesh is returning the msg "error resource '/cluster/ha/status/manager_status' does not define child links" root@pve:~/Proxmox-load-balancer# ./plb.py INFO | START Load-balancer! DEBUG | Authorization attempt... DEBUG | Successful authentication. Response code: 200 DEBUG | init when creating a Cluster object DEBUG | Starting Cluster.cluster_name DEBUG | Information about the cluster name has been received. Response code: 200 DEBUG | Launching Cluster.cluster_items DEBUG | Attempt to get information about the cluster... DEBUG | Information about the cluster has been received. Response code: 200 DEBUG | Launching Cluster.cluster_hosts DEBUG | Attempt to get information about the cluster HA manager... DEBUG | Information about the cluster HA Manager has been received. Response code: 200 DEBUG | Launching Cluster.cluster_vms DEBUG | Launching Cluster.cluster_membership DEBUG | Launching Cluster.cluster_cpu INFO | This server (pve) is not the current cluster master, pve3 is. Waiting 300 seconds.

image image

cvk98 commented 2 years ago

The mode of operation only on the master node of the cluster was added only so that it was possible to roll the balancer on all nodes of the cluster. And so that they all do not start working at once - you need to include in the config a check on whether the node is the master of the HA cluster. If you have a script running on a single node or on a virtual machine, you need to install "only_on_master: OFF" in the config. This should solve your problem. And running the script in one instance only on the master node of the HA cluster with "only_on_master: ON" is pointless. Since this is not permanent and the master may change over time.

cvk98 commented 2 years ago

Can I close issue?

BerKer999 commented 2 years ago

yes, thanks thanks for your help