lstein / Net-ISP-Balance

Set of scripts to load-balance your Internet connection across two or more ISPs with auto failover
Artistic License 2.0
204 stars 49 forks source link

debug mode not working #22

Open quams opened 7 years ago

quams commented 7 years ago

Hoi!

I am setting up my dual-isp router, but still using only one of the internet connections while doing that.

For some reasons the --debug is not working. It acts like a verbose, meaning all the rules and routes are getting dumped to stdout, but they are still executed and the lsm is started.

While this is only a minor bug, it is still tremendously annoying, since I have to take down everything by hand and start my normal internet again.

blue skies Jan

quams commented 7 years ago

I found the reason for that behaviour. The cause is that, at the end of the execution in load_balance.pl the lsm is started via a separate function. There is no check for debug mode for this, but _balancer_eventscript calls _loadbalance.pl up which in return sets routes and iptables.

I think the lsm starting command was supposed to be like this:

--- a/bin/load_balance.pl
+++ b/bin/load_balance.pl
@@ -275,7 +275,7 @@ if ($bal->operating_mode eq 'failover') {
 }
 $bal->set_routes_and_firewall();
 kill_lsm() unless @ARGV;
-start_or_reload_lsm($bal);
+start_or_reload_lsm($bal) unless $DEBUG;

 exit 0;

At least that works for me.

blue skies Jan

bill-mcgonigle commented 2 years ago

This WFM too.

dewhisna commented 6 months ago

Good catch @quams -- you should open a PR to get this fix landed. I had the same issue here trying to configure and set things up. And more inconveniently, I was working on the setup via another node on my LAN rather than upstairs in the computer room where the server is located. Debug mode wasn't supposed to launch the LSM, but it did, and just like you found, it relaunched the balancing script, which, since I was still working on my setup configuration that was quite incomplete still, took down my entire network and I had to trek upstairs and get it back online, as it had reconfigured iptables and routes to where I could no longer talk to it remotely.