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

rawlin 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 bf10033  Fix LetsEncryptDnsChallengeWatcher config location (#5280)
bf10033 is described below

commit bf100338b405cf3f5e5d0d318f8f7c4772f16115
Author: Steve Hamrick <[email protected]>
AuthorDate: Fri Nov 13 10:56:47 2020 -0700

    Fix LetsEncryptDnsChallengeWatcher config location (#5280)
    
    * Fix LE Watcher
    
    * Forgot Changelog
    
    * Use tabs
    
    Co-authored-by: Steve Hamrick <[email protected]>
---
 CHANGELOG.md                                       |  5 ++++-
 .../core/ds/LetsEncryptDnsChallengeWatcher.java    | 26 ++++++++++++++++------
 .../src/main/webapp/WEB-INF/applicationContext.xml | 15 +++++++------
 3 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 776a79b..0ebce43 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,7 +9,10 @@ The format is based on [Keep a 
Changelog](http://keepachangelog.com/en/1.0.0/).
 - Added locationByDeepCoverageZone to the `crs/stats/ip/{ip}` endpoint in the 
Traffic Router API
 
 ### Fixed
-- Fixed #5274 - CDN in a Box's Traffic Vault image failed to build due to 
Basho's repo responding with 402 Payment Required. The repo has been removed 
from the image.
+- [#5274](https://github.com/apache/trafficcontrol/issues/5274) - CDN in a 
Box's Traffic Vault image failed to build due 
+    to Basho's repo responding with 402 Payment Required. The repo has been 
removed from the image.
+- [#5069](https://github.com/apache/trafficcontrol/issues/5069) - For 
LetsEncryptDnsChallengerWatcher in Traffic Router,
+    the cr-config location is configurable instead of only looking at 
`/opt/traffic_router/db/cr-config.json`
 
 ## [5.0.0] - 2020-10-20
 ### Added
diff --git 
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/LetsEncryptDnsChallengeWatcher.java
 
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/LetsEncryptDnsChallengeWatcher.java
index d568085..f009f6a 100644
--- 
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/LetsEncryptDnsChallengeWatcher.java
+++ 
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/LetsEncryptDnsChallengeWatcher.java
@@ -29,6 +29,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
 import org.apache.log4j.Logger;
 
 import java.io.*;
+import java.nio.file.Path;
 import java.time.Instant;
 import java.util.HashMap;
 import java.util.List;
@@ -36,13 +37,10 @@ import java.util.List;
 public class LetsEncryptDnsChallengeWatcher extends AbstractResourceWatcher {
     private static final Logger LOGGER = 
Logger.getLogger(LetsEncryptDnsChallengeWatcher.class);
     public static final String DEFAULT_LE_DNS_CHALLENGE_URL = 
"https://${toHostname}/api/2.0/letsencrypt/dnsrecords/";;
-    private static final String configFile = 
"/opt/traffic_router/db/cr-config.json";
 
+    private String configFile;
     private ConfigHandler configHandler;
-
-    public void setConfigHandler(final ConfigHandler configHandler) {
-        this.configHandler = configHandler;
-    }
+    private Path databasesDirectory;
 
     public LetsEncryptDnsChallengeWatcher() {
         setDatabaseUrl(DEFAULT_LE_DNS_CHALLENGE_URL);
@@ -134,7 +132,7 @@ public class LetsEncryptDnsChallengeWatcher extends 
AbstractResourceWatcher {
 
     private String readConfigFile() {
         try {
-            final InputStream is = new FileInputStream(configFile);
+            final InputStream is = new 
FileInputStream(databasesDirectory.resolve(configFile).toString());
             final BufferedReader buf = new BufferedReader(new 
InputStreamReader(is));
             String line = buf.readLine();
             final StringBuilder sb = new StringBuilder();
@@ -144,7 +142,7 @@ public class LetsEncryptDnsChallengeWatcher extends 
AbstractResourceWatcher {
             }
             return sb.toString();
         } catch (Exception e) {
-            LOGGER.error("Could not read cr-config file.");
+            LOGGER.error("Could not read cr-config file " + configFile + ".");
             return null;
         }
     }
@@ -178,4 +176,18 @@ public class LetsEncryptDnsChallengeWatcher extends 
AbstractResourceWatcher {
         return newStaticDnsEntriesNode;
     }
 
+    public void setConfigHandler(final ConfigHandler configHandler) {
+        this.configHandler = configHandler;
+    }
+    public ConfigHandler getConfigHandler() {
+        return this.configHandler;
+    }
+
+    public void setDatabasesDirectory(final Path databasesDirectory) {
+        this.databasesDirectory = databasesDirectory;
+    }
+
+    public void setConfigFile(final String configFile) {
+        this.configFile = configFile;
+    }
 }
diff --git a/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml 
b/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml
index 544cf55..55ef754 100644
--- a/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml
@@ -89,14 +89,15 @@
                <property name="steeringRegistry" ref="steeringRegistry" />
        </bean>
 
-    <bean id="letsEncryptDnsChallengeWatcher" 
class="com.comcast.cdn.traffic_control.traffic_router.core.ds.LetsEncryptDnsChallengeWatcher">
-        <property name="executorService" ref="ScheduledExecutorService" />
-        <property name="databasesDirectory" ref="databasesDir" />
-        <property name="databaseName" 
value="$[cache.letsencrypt.database:letsencrypt.json]" />
-        <property name="trafficOpsUtils" ref="trafficOpsUtils" />
-        <property name="trafficRouterManager" ref="trafficRouterManager" />
+       <bean id="letsEncryptDnsChallengeWatcher" 
class="com.comcast.cdn.traffic_control.traffic_router.core.ds.LetsEncryptDnsChallengeWatcher">
+               <property name="executorService" ref="ScheduledExecutorService" 
/>
+               <property name="databasesDirectory" ref="databasesDir" />
+               <property name="databaseName" 
value="$[cache.letsencrypt.database:letsencrypt.json]" />
+               <property name="trafficOpsUtils" ref="trafficOpsUtils" />
+               <property name="trafficRouterManager" 
ref="trafficRouterManager" />
                <property name="pollingInterval" value="60000" />
-        <property name="configHandler" ref="ConfigHandler" />
+               <property name="configFile" 
value="$[cache.config.json:cr-config.json]" />
+               <property name="configHandler" ref="ConfigHandler" />
        </bean>
 
        <bean id="certificatesQueue" 
class="java.util.concurrent.ArrayBlockingQueue" >

Reply via email to