<div dir="ltr"><p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">Hi there,</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"> </span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">I’m hoping to garner some
assistance and advice as I’m hoping I could replace an existing load balancing
solution entirely with PowerDNS and Lua records.</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"> </span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">I’ve put quite a bit of
work into this, but I’m reaching some dead ends that I hope someone experienced
might be able to help me with.</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"> </span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">What I’m load balancing
is a geographically dispersed object storage system, consisting of three sites;
each site consists of eight nodes, and any of these can answer a query.</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">The system can run with
one out of the three sites being completely down, or any number of the
constituent nodes being down, and we take advantage of it in undertaking maintenance.</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"> </span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">Currently in my approach,
I undertake a DNS-based weighted round robin around each of the sites; weighted
because each site stores a different capacity, and I want to prefer the least
heavily utilised site. This weighted round robin takes into account the
overall health of the nodes making up each site and won’t respond with a site
that has a total outage. The response should be a list of all the addresses of
healthy nodes, potentially eight IP’s. There are two health checks that probe
each node, one on an HTTP endpoint, and another on HTTPS.</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"> </span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">The weighted round robin,
I understand I can achieve in PowerDNS with a LUA record with the pickwrandom
command.</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">That was the easy part, I
also thought I could utilise a separate record to store the weighting
configuration in.</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">What I’ve come up with
there is:</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"> </span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito</span><span style="font-family:Consolas">-weighting.</span><span style="font-family:Consolas">internal </span><span style="font-family:Consolas">0    IN  LUA LUA
  "w</span><span style="font-family:Consolas">eightinga</span><span style="font-family:Consolas">={'110'}; </span><span style="font-family:Consolas">weightingb</span><span style="font-family:Consolas">={'50'}; </span><span style="font-family:Consolas">weightingc</span><span style="font-family:Consolas">={'175'}"</span><span style="font-family:Consolas"></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito</span><span style="font-family:Consolas">.</span><span style="font-family:Consolas">internal      
    </span><span style="font-family:Consolas">0    IN  LUA CNAME "; include('</span><span style="font-family:Consolas">caimito</span><span style="font-family:Consolas">-weighting.</span><span style="font-family:Consolas">internal</span><span style="font-family:Consolas">'); return
pickwrandom({ {w</span><span style="font-family:Consolas">eightinga</span><span style="font-family:Consolas">,  '</span><span style="font-family:Consolas">caimito-a</span><span style="font-family:Consolas">.</span><span style="font-family:Consolas">internal</span><span style="font-family:Consolas">'}, {w</span><span style="font-family:Consolas">eightingb</span><span style="font-family:Consolas">,  '</span><span style="font-family:Consolas">caimito-b</span><span style="font-family:Consolas">.</span><span style="font-family:Consolas">internal</span><span style="font-family:Consolas">'}, {w</span><span style="font-family:Consolas">eightingc</span><span style="font-family:Consolas">, '</span><span style="font-family:Consolas">caimito-c</span><span style="font-family:Consolas">.</span><span style="font-family:Consolas">internal</span><span style="font-family:Consolas">'}</span><span style="font-family:Consolas"> })</span><span style="font-family:Consolas">"</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"> </span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">I had that working before
I shifted it to using variables as the weighting, and I can’t understand why
it’s failing me now. I’m also not sure how I would approach a site having no
healthy IP addresses available.</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"> </span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">That was using records
like this:</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-a.internal     
0   IN  A   10.10.0.1</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-a.internal     
0   IN  A   10.10.0.2</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-a.internal     
0   IN  A   10.10.0.3</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-b.internal 
    0   IN  A   10.10.1.1</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-b.internal     
0   IN  A   10.10.1.2</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-b.internal     
0   IN  A   10.10.1.3</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-c.internal     
0   IN  A   10.10.2.1</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-c.internal     
0   IN  A   10.10.2.2</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-c.internal     
0   IN  A   10.10.2.3</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"> </span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">Whereas what I’d like to
do is something more akin to:</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-a.internal     
0   IN  LUA  A   "ifurlup('<a href="http://10.10.0.1:9020/?ping">http://10.10.0.1:9020/?ping</a>',
{'10.10.0.1'}, {stringmatch='Data Node is Available'})"</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-a.internal     
0   IN  LUA  A  
"ifurlup('<a href="http://10.10.0.2:9020/?ping">http://10.10.0.2:9020/?ping</a>', {'10.10.0.2'}, {stringmatch='Data
Node is Available'})"</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-a.internal     
0   IN  LUA  A  
"ifurlup('<a href="http://10.10.0.3:9020/?ping">http://10.10.0.3:9020/?ping</a>', {'10.10.0.3'}, {stringmatch='Data
Node is Available'})"</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-b.internal     
0   IN  LUA  A  
"ifurlup('<a href="http://10.10.1.1:9020/?ping">http://10.10.1.1:9020/?ping</a>', {'10.10.1.1'}, {stringmatch='Data
Node is Available'})"</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-b.internal     
0   IN  LUA  A  
"ifurlup('<a href="http://10.10.1.2:9020/?ping">http://10.10.1.2:9020/?ping</a>', {'10.10.1.2'}, {stringmatch='Data
Node is Available'})"</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-b.internal     
0   IN  LUA  A  
"ifurlup('<a href="http://10.10.1.3:9020/?ping">http://10.10.1.3:9020/?ping</a>', {'10.10.1.3'}, {stringmatch='Data
Node is Available'})"</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-c.internal     
0   IN  LUA  A  
"ifurlup('<a href="http://10.10.2.1:9020/?ping">http://10.10.2.1:9020/?ping</a>', {'10.10.2.1'}, {stringmatch='Data
Node is Available'})"</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-c.internal     
0   IN  LUA  A  
"ifurlup('<a href="http://10.10.2.2:9020/?ping">http://10.10.2.2:9020/?ping</a>', {'10.10.2.2'}, {stringmatch='Data
Node is Available'})"</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">caimito-c.internal     
0   IN  LUA  A  
"ifurlup('<a href="http://10.10.2.3:9020/?ping">http://10.10.2.3:9020/?ping</a>', {'10.10.2.3'}, {stringmatch='Data
Node is Available'})"</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"> </span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">Only somehow running a
logical and between two different ifurlup’s:</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">"if (ifurlup('<a href="http://10.10.0.1:9020/?ping">http://10.10.0.1:9020/?ping</a>',
{'10.10.0.1'}, {stringmatch='Data Node is Available'})) and
(ifurlup('<a href="https://10.10.0.1:9021/?ping">https://10.10.0.1:9021/?ping</a>', {'10.10.0.1'}, {stringmatch='Data Node
is Available'}))"</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"> </span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">However, I understand
that the ifurlup health checks don’t work that way because they fallback
returning a random result when all tests fail, whereas I want no result on a
failure.</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">I spotted the feature
request to ‘add a true/false flag to LUA test functions’ (<a href="https://github.com/PowerDNS/pdns/issues/7468" style="color:rgb(5,99,193)">https://github.com/PowerDNS/pdns/issues/7468</a>)
that might aid me here, but it wasn’t implemented.</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"> </span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">I also caught a that in
the design of the backupSelector the was originally a fallback of ‘none’ (<a href="https://github.com/PowerDNS/pdns/pull/6894" style="color:rgb(5,99,193)">https://github.com/PowerDNS/pdns/pull/6894</a>),
which might have also been useful in my case, but I understand that was removed
before merge.</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"> </span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">If anyone can offer
suggestions or pointers on how I might best approach any of this, I’m all ears.</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"> </span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">Thanks in advance.</span></p>

<p class="MsoNormal" style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas">Adam.</span></p></div>