Skip to content

Commit

Permalink
set next ip
Browse files Browse the repository at this point in the history
  • Loading branch information
arteck committed Jan 2, 2025
1 parent 3f5f395 commit 862e726
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions lib/proxmox.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,16 @@ class ProxmoxUtils {
this.sharedMap = {};

this.stopped = false;

this.communicationErrorCounter = 0;
}

setNextUrlMain(id) {
if (typeof id === 'number') {
this.currentIpId = id - 1;
}

this.currentIpId++;
if (this.currentIpId === this.ipList.length) {

if (this.currentIpId >= this.ipList.length) {
this.currentIpId = 0;
}

// if (this.ipList[this.currentIpId]) {
// this.currentIpId = 0;
// }

this.URL = `https://${this.ipList[this.currentIpId]}:${this.port}/api2/json`;
return this.URL;
}
Expand Down Expand Up @@ -287,7 +279,6 @@ class ProxmoxUtils {
})
.then((response) => {
this.adapter.log.debug(`received ${response.status} response from ${pathU} with content: ${JSON.stringify(response.data)}`);
this.communicationErrorCounter = 0;

if (response.status === 500 || response.status === 595 || response.status === 599) {
reject(response.status + ' - ' + response.data);
Expand All @@ -310,13 +301,8 @@ class ProxmoxUtils {

this.adapter.log.warn(`${additional} -- Use Next Proxmox Host because of communication failure ${this.URL}${url}`);

this.communicationErrorCounter++;
// We experienced error the same as we have servers available, so no chance to retry another server
// select next server and try again
this.setNextUrlMain();
if (this.communicationErrorCounter >= this.ipList.length) {
// this.adapter.log.error(`Error received response from ${error.config.url}`);
this.setNextUrlMain(0);
}

this.ticket(async () => {
// Retry with new ticket
Expand Down

0 comments on commit 862e726

Please sign in to comment.