Changeset 767


Ignore:
Timestamp:
06/28/17 18:20:30 (7 years ago)
Author:
Kris Deugau
Message:

/trunk

File a sharp edge off ALIAS handling; in an edge case where the target
name goes AWOL for a couple of export cycles, the cache would be invalidated.
Also fix related issues on record update where the cache was or wasn't
being updated when it should have been. See #55.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r764 r767  
    14091409    if (!$iplist) {
    14101410      # not fatal since we do the lookup on export as well
    1411       return ('WARN',
    1412         join("\n", $errstr, "No cached data and no live DNS data for ALIAS target ${$args{val}};  record may be SKIPPED on export!") );
     1411      $warnmsg = "No cached data and no live DNS data for ALIAS target ${$args{val}};  record may be SKIPPED on export!";
    14131412    }
    14141413  }
    14151414
    14161415  # munge the insert/update fieldlist and data array
    1417   if ($iplist ne $liveips) {
     1416  # note we always force this;  if the target has changed the cached data is almost certainly invalid anyway
     1417  if ($liveips && ($iplist ne $liveips)) {
    14181418    ${$args{fields}} .= "auxdata,";
    14191419    push @{$args{vallist}}, $liveips;
    14201420  }
    14211421
    1422   return ('WARN', $warnmsg) if $warnmsg;
     1422  return ('WARN', join("\n", $errstr, $warnmsg) ) if $warnmsg;
    14231423 
    14241424  return ('OK','OK');
     
    14381438  my $reply = $res->query($target);
    14391439
    1440   my $liveips;
     1440  my $liveips = '';
    14411441  if ($reply) {
    14421442    # default to a one-hour TTL, which should be variously modified down the chain.  Arguably this could
     
    14531453    $minttl = 60 if $minttl < 60;
    14541454    # we don't need this to be perfectly correct IP address order, just consistent.
    1455     $liveips = "$minttl:".join(':', sort(@newlist));
     1455    $liveips = "$minttl:".join(':', sort(@newlist)) if @newlist;
     1456#fixme:  should it be a formal error case if there are no A records returned?
    14561457  } else {
    14571458    $errstr = "Lookup failure retrieving ALIAS IP list: ".$res->errorstring;
     
    67606761
    67616762    my ($iplist) = $self->{dbh}->selectrow_array("SELECT auxdata FROM records WHERE record_id = ?", undef, $recid);
     6763    $iplist = '' if !$iplist;
    67626764
    67636765    # shared target-name-to-IP converter
    67646766    my $liveips = $self->_grab_65300($recid, $val);
    6765     if ($iplist ne $liveips) {
     6767    # only update the cache if the live lookup actually returned data
     6768    if ($liveips && ($iplist ne $liveips)) {
    67666769      $self->{dbh}->do("UPDATE records SET auxdata = ? WHERE record_id = ?", undef, $liveips, $recid);
    67676770      $iplist = $liveips;
Note: See TracChangeset for help on using the changeset viewer.