Skip to content

Commit

Permalink
Revert "Traffic Router DNS zone calculation optimizations (#7622)"
Browse files Browse the repository at this point in the history
This reverts commit dcf6e31.
  • Loading branch information
zrhoffman committed Jul 11, 2023
1 parent 8742cfb commit c6fcfea
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 113 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [unreleased]
### Added
- [#7622](https://github.com/apache/trafficcontrol/pull/7622) *Traffic Router* Added further optimization to TR's algorithm of figuring out the zone for an incoming request.
- [#7609](https://github.com/apache/trafficcontrol/pull/7609) *Traffic Portal* Added Scope Query Param to SSO login.
- [#7450](https://github.com/apache/trafficcontrol/pull/7450) *Traffic Ops* Removed hypnotoad section and added listen field to traffic_ops_golang section in order to simplify cdn config.
- [#7290](https://github.com/apache/trafficcontrol/pull/7302) *Traffic Monitor* Update TM results with hostname from via header, syncronize health on caches with same service address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,11 @@ public class ConfigHandler {
private final AtomicBoolean cancelled = new AtomicBoolean(false);
private final AtomicBoolean isProcessing = new AtomicBoolean(false);

private final Map<String, DeliveryService> fqdnToDeliveryService = new HashMap<>();
private final static String NEUSTAR_POLLING_URL = "neustar.polling.url";
private final static String NEUSTAR_POLLING_INTERVAL = "neustar.polling.interval";

private final static String LOCALIZATION_METHODS = "localizationMethods";

public Map<String, DeliveryService> getFQDNToDeliveryServiceMap() {
return fqdnToDeliveryService;
}

public String getConfigDir() {
return configDir;
}
Expand Down Expand Up @@ -187,7 +182,7 @@ public boolean processConfig(final String jsonStr) throws JsonUtilsException, IO
cacheRegister.setStats(stats);
parseTrafficOpsConfig(config, stats);

final Map<String, DeliveryService> deliveryServiceMap = parseDeliveryServiceConfig(JsonUtils.getJsonNode(jo, deliveryServicesKey), cacheRegister);
final Map<String, DeliveryService> deliveryServiceMap = parseDeliveryServiceConfig(JsonUtils.getJsonNode(jo, deliveryServicesKey));

parseCertificatesConfig(config);
certificatesPublisher.setDeliveryServicesJson(deliveryServicesJson);
Expand Down Expand Up @@ -453,7 +448,7 @@ private void parseCacheConfig(final JsonNode contentServers, final CacheRegister
statTracker.initialize(statMap, cacheRegister);
}

private Map<String, DeliveryService> parseDeliveryServiceConfig(final JsonNode allDeliveryServices, final CacheRegister cacheRegister) throws JsonUtilsException {
private Map<String, DeliveryService> parseDeliveryServiceConfig(final JsonNode allDeliveryServices) throws JsonUtilsException {
final Map<String,DeliveryService> deliveryServiceMap = new HashMap<>();

final Iterator<String> deliveryServiceIter = allDeliveryServices.fieldNames();
Expand All @@ -474,9 +469,6 @@ private Map<String, DeliveryService> parseDeliveryServiceConfig(final JsonNode a

deliveryService.setDns(isDns);
deliveryServiceMap.put(deliveryServiceId, deliveryService);
fqdnToDeliveryService.put(deliveryService.getRoutingName() + "." + deliveryService.getDomain(), deliveryService);
fqdnToDeliveryService.put("_." + deliveryService.getDomain(), deliveryService);
cacheRegister.setFQDNToDeliveryServiceMap(fqdnToDeliveryService);
}

return deliveryServiceMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,6 @@ private void lookup(final Name qname, final int qtype, final InetAddress clientA
return;
}

if (clientAddress != null && clientAddress.getHostName().equals("_")) {
response.getHeader().setRcode(Rcode.NXDOMAIN);
response.getHeader().setFlag(Flags.AA);
addDenialOfExistence(qname, zone, response, flags);
addSOA(zone, response, Section.AUTHORITY, flags);
return;
}

final SetResponse sr = zone.findRecords(qname, qtype);

if (sr.isSuccessful()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class CacheRegister {
private Map<String,Cache> allCaches;
private TreeSet<DeliveryServiceMatcher> deliveryServiceMatchers;
private Map<String, DeliveryService> dsMap;
private Map<String, DeliveryService> fqdnToDeliveryServiceMap;
private JsonNode config;
private JsonNode stats;
private int edgeTrafficRouterCount;
Expand Down Expand Up @@ -149,10 +148,6 @@ public void setDeliveryServiceMatchers(final TreeSet<DeliveryServiceMatcher> mat
* @return the DeliveryService that matches the request
*/
public DeliveryService getDeliveryService(final Request request) {
final String requestName = request.getHostname();
if (getFQDNToDeliveryServiceMap() != null && getFQDNToDeliveryServiceMap().get(requestName) != null) {
return getFQDNToDeliveryServiceMap().get(requestName);
}
if (deliveryServiceMatchers == null) {
return null;
}
Expand Down Expand Up @@ -184,14 +179,6 @@ public void setDeliveryServiceMap(final Map<String, DeliveryService> dsMap) {
this.dsMap = dsMap;
}

public Map<String, DeliveryService> getFQDNToDeliveryServiceMap() {
return fqdnToDeliveryServiceMap;
}

public void setFQDNToDeliveryServiceMap(final Map<String, DeliveryService> fqdnToDeliveryServiceMap) {
this.fqdnToDeliveryServiceMap = fqdnToDeliveryServiceMap;
}

public JsonNode getTrafficRouters() {
return trafficRouters;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,13 @@

package org.apache.traffic_control.traffic_router.core.edge;

import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.traffic_control.traffic_router.core.ds.DeliveryService;
import org.apache.traffic_control.traffic_router.core.ds.DeliveryServiceMatcher;
import org.apache.traffic_control.traffic_router.core.request.DNSRequest;
import org.apache.traffic_control.traffic_router.core.request.HTTPRequest;
import org.apache.traffic_control.traffic_router.core.request.Request;
import org.apache.traffic_control.traffic_router.core.util.JsonUtilsException;
import org.junit.Before;
import org.junit.Test;
import org.xbill.DNS.Name;
import org.xbill.DNS.TextParseException;
import org.xbill.DNS.Type;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeSet;

import static org.apache.traffic_control.traffic_router.core.ds.DeliveryServiceMatcher.Type.HOST;
Expand Down Expand Up @@ -100,75 +90,4 @@ public void itReturnsNullForDeliveryServiceWhenItHasNoMatchers() {
httpRequest.setPath("foo/abcde/bar");
assertThat(cacheRegister.getDeliveryService(httpRequest), nullValue());
}

@Test
public void itReturnsDeliveryServiceFromFQDNMapForHTTPRequest() throws JsonUtilsException {
String requestName = "http://foo.service01.kabletown.com/";
HTTPRequest httpRequest = new HTTPRequest();
httpRequest.setHostname("foo.service01.kabletown.com");
httpRequest.setRequestedUrl(requestName);
Map<String, DeliveryService> map = new HashMap<>();

ObjectNode node = JsonNodeFactory.instance.objectNode();
ArrayNode domainNode = node.putArray("domains");
domainNode.add("kabletown.com");
node.put("routingName","foo");
node.put("coverageZoneOnly", false);
DeliveryService ds = new DeliveryService("service01", node);

map.put("foo.service01.kabletown.com", ds);
map.put("_.service01.kabletown.com", ds);
cacheRegister.setFQDNToDeliveryServiceMap(map);

DeliveryService answer = cacheRegister.getDeliveryService(httpRequest);
assertThat("FQDNToDeliveryServiceMap was expected to have the key foo.service01.kabletown.com",
cacheRegister.getFQDNToDeliveryServiceMap().containsKey("foo.service01.kabletown.com"));
assertThat("Returned Delivery Service was expected to have the ID service01",
answer.getId().equals("service01"));


httpRequest.setRequestedUrl("http://_.service01.kabletown.com");
answer = cacheRegister.getDeliveryService(httpRequest);
assertThat("FQDNToDeliveryServiceMap was expected to have the key _.service01.kabletown.com",
cacheRegister.getFQDNToDeliveryServiceMap().containsKey("_.service01.kabletown.com"));
assertThat("Returned Delivery Service was expected to have the ID service01",
answer.getId().equals("service01"));
}

@Test
public void itReturnsDeliveryServiceFromFQDNMapForDNSRequest() throws JsonUtilsException, TextParseException {
final Name name = Name.fromString("edge.example.com.");
DNSRequest dnsRequest = new DNSRequest("example.com", name, Type.A);
dnsRequest.setClientIP("10.10.10.10");
dnsRequest.setHostname(name.relativize(Name.root).toString());

Map<String, DeliveryService> map = new HashMap<>();

ObjectNode node = JsonNodeFactory.instance.objectNode();
ArrayNode domainNode = node.putArray("domains");
domainNode.add("example.com");
node.put("routingName","edge");
node.put("coverageZoneOnly", false);
DeliveryService ds = new DeliveryService("example", node);

map.put("edge.example.com", ds);
map.put("_.example.com", ds);
cacheRegister.setFQDNToDeliveryServiceMap(map);

DeliveryService answer = cacheRegister.getDeliveryService(dnsRequest);
assertThat("FQDNToDeliveryServiceMap was expected to have the key edge.example.com",
cacheRegister.getFQDNToDeliveryServiceMap().containsKey("edge.example.com"));
assertThat("Returned Delivery Service was expected to have the ID example",
answer.getId().equals("example"));

final Name underscoreName = Name.fromString("_.example.com");
dnsRequest = new DNSRequest("example.com", underscoreName, Type.A);
dnsRequest.setClientIP("10.10.10.10");
dnsRequest.setHostname(name.relativize(Name.root).toString());
answer = cacheRegister.getDeliveryService(dnsRequest);
assertThat("FQDNToDeliveryServiceMap was expected to have the key _.example.com",
cacheRegister.getFQDNToDeliveryServiceMap().containsKey("_.example.com"));
assertThat("Returned Delivery Service was expected to have the ID example",
answer.getId().equals("example"));
}
}

0 comments on commit c6fcfea

Please sign in to comment.