This is an automated email from the ASF dual-hosted git repository.

zrhoffman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 7b10e1d  Fix TR warning for caches without ipv4 addresses (#5372)
7b10e1d is described below

commit 7b10e1d00cf1d7d19f2f4ca34aa6a98d8ad174c8
Author: Rawlin Peters <[email protected]>
AuthorDate: Fri Dec 11 18:10:16 2020 -0700

    Fix TR warning for caches without ipv4 addresses (#5372)
    
    It is valid for a cache to not have an ipv4 address, so we should not
    log a warning in that case.
---
 CHANGELOG.md                                       |  1 +
 .../traffic_router/core/dns/ZoneManager.java       | 26 ++++++++++++----------
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 67c2cbd..5a63247 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ The format is based on [Keep a 
Changelog](http://keepachangelog.com/en/1.0.0/).
 
 ### Fixed
 - [#5195](https://github.com/apache/trafficcontrol/issues/5195) - Correctly 
show CDN ID in Changelog during Snap
+- Fixed Traffic Router logging unnecessary warnings for IPv6-only caches
 - [#5294](https://github.com/apache/trafficcontrol/issues/5294) - TP ag grid 
tables now properly persist column filters
     on page refresh.
 - [#5295](https://github.com/apache/trafficcontrol/issues/5295) - TP 
types/servers table now clears all filters instead
diff --git 
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/dns/ZoneManager.java
 
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/dns/ZoneManager.java
index 64ee8b8..e53845e 100644
--- 
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/dns/ZoneManager.java
+++ 
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/dns/ZoneManager.java
@@ -814,12 +814,7 @@ public class ZoneManager extends Resolver {
                                final String domain = parts[1];
 
                                dsMap.put(domain, ds);
-                               List<Record> zholder = zoneMap.get(domain);
-
-                               if (zholder == null) {
-                                       zholder = new ArrayList<Record>();
-                                       zoneMap.put(domain, zholder);
-                               }
+                               final List<Record> zholder = 
zoneMap.computeIfAbsent(domain, k -> new ArrayList<>());
 
                                final String superdomain = domain.split("\\.", 
2)[1];
 
@@ -835,16 +830,23 @@ public class ZoneManager extends Resolver {
                                        final Name name = newName(fqdn);
                                        final JsonNode ttl = ds.getTtls();
 
-                                       try {
-                                               zholder.add(new ARecord(name, 
DClass.IN, ZoneUtils.getLong(ttl, "A", 60), c.getIp4()));
-                                       } catch (IllegalArgumentException e) {
-                                               LOGGER.warn(e + " : " + 
c.getIp4());
+                                       final InetAddress ip4 = c.getIp4();
+                                       if (ip4 != null) {
+                                               try {
+                                                       zholder.add(new 
ARecord(name, DClass.IN, ZoneUtils.getLong(ttl, "A", 60), ip4));
+                                               } catch 
(IllegalArgumentException e) {
+                                                       LOGGER.warn(e + " : " + 
ip4, e);
+                                               }
                                        }
 
                                        final InetAddress ip6 = c.getIp6();
 
-                                       if (ip6 != null && ds != null && 
ds.isIp6RoutingEnabled()) {
-                                               zholder.add(new 
AAAARecord(name, DClass.IN, ZoneUtils.getLong(ttl, AAAA, 60), ip6));
+                                       if (ip6 != null && 
ds.isIp6RoutingEnabled()) {
+                                           try {
+                                                       zholder.add(new 
AAAARecord(name, DClass.IN, ZoneUtils.getLong(ttl, AAAA, 60), ip6));
+                                               } catch 
(IllegalArgumentException e) {
+                                                       LOGGER.warn(e + " : " + 
ip6, e);
+                                               }
                                        }
                                } catch (org.xbill.DNS.TextParseException e) {
                                        LOGGER.error("Caught fatal exception 
while generating zone data for " + fqdn  + "!", e);

Reply via email to