aboutsummaryrefslogtreecommitdiffstats
path: root/routing-generator/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'routing-generator/src/main/java')
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/Router.java2
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java10
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingTable.java2
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/Nginx.java16
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxConfig.java2
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxHealthClient.java2
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxMetricsReporter.java2
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxPath.java2
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/restapi/AkamaiHandler.java2
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/restapi/package-info.java2
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/HealthStatus.java2
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/RoutingStatus.java2
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/RoutingStatusClient.java2
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/ServerGroup.java2
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/package-info.java2
15 files changed, 32 insertions, 20 deletions
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/Router.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/Router.java
index c7cd5a75359..5c9535ba09d 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/Router.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/Router.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.routing;
/**
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java
index cad69d35b55..f86ccc3df18 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingGenerator.java
@@ -1,6 +1,8 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.routing;
+import ai.vespa.cloud.Environment;
+import ai.vespa.cloud.SystemInfo;
import com.yahoo.cloud.config.LbServicesConfig;
import com.yahoo.component.AbstractComponent;
import com.yahoo.component.annotation.Inject;
@@ -29,7 +31,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -61,13 +62,14 @@ public class RoutingGenerator extends AbstractComponent {
private volatile RoutingTable routingTable = null;
@Inject
- public RoutingGenerator(ZoneConfig zoneConfig, RoutingStatus routingStatus, Metric metric) {
+ public RoutingGenerator(ZoneConfig zoneConfig, RoutingStatus routingStatus, Metric metric, SystemInfo systemInfo) {
this(new ConfigSourceSet(zoneConfig.configserver()), new Nginx(FileSystems.getDefault(),
new ProcessExecuter(),
Sleeper.DEFAULT,
Clock.systemUTC(),
routingStatus,
- metric),
+ metric,
+ systemInfo.zone().environment() == Environment.prod),
Clock.systemUTC());
}
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingTable.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingTable.java
index 7f9f04ed691..b23b15cc85e 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingTable.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/RoutingTable.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.routing;
import com.google.common.hash.Hashing;
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/Nginx.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/Nginx.java
index b197bff7a51..b6a4cc98038 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/Nginx.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/Nginx.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.routing.nginx;
import com.yahoo.collections.Pair;
@@ -48,16 +48,18 @@ public class Nginx implements Router {
private final Clock clock;
private final RoutingStatus routingStatus;
private final Metric metric;
+ private final boolean outputRoutingDiff;
private final Object monitor = new Object();
- public Nginx(FileSystem fileSystem, ProcessExecuter processExecuter, Sleeper sleeper, Clock clock, RoutingStatus routingStatus, Metric metric) {
+ public Nginx(FileSystem fileSystem, ProcessExecuter processExecuter, Sleeper sleeper, Clock clock, RoutingStatus routingStatus, Metric metric, boolean outputRoutingDiff) {
this.fileSystem = Objects.requireNonNull(fileSystem);
this.processExecuter = Objects.requireNonNull(processExecuter);
this.sleeper = Objects.requireNonNull(sleeper);
this.clock = Objects.requireNonNull(clock);
this.routingStatus = Objects.requireNonNull(routingStatus);
this.metric = Objects.requireNonNull(metric);
+ this.outputRoutingDiff = outputRoutingDiff;
}
@Override
@@ -89,6 +91,7 @@ public class Nginx implements Router {
private void loadConfig(int upstreamCount) throws IOException {
Path configPath = NginxPath.config.in(fileSystem);
Path tempConfigPath = NginxPath.temporaryConfig.in(fileSystem);
+ String routingDiff = "";
try {
String currentConfig = Files.readString(configPath);
String newConfig = Files.readString(tempConfigPath);
@@ -96,6 +99,8 @@ public class Nginx implements Router {
Files.deleteIfExists(tempConfigPath);
return;
}
+ if(outputRoutingDiff)
+ routingDiff = " with diff:\n" + getDiff(configPath, tempConfigPath);
Path rotatedConfig = NginxPath.config.rotatedIn(fileSystem, clock.instant());
atomicCopy(configPath, rotatedConfig);
} catch (NoSuchFileException ignored) {
@@ -104,12 +109,17 @@ public class Nginx implements Router {
Files.move(tempConfigPath, configPath, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
metric.add(CONFIG_RELOADS_METRIC, 1, null);
// Retry reload. Same rationale for retrying as in testConfig()
- LOG.info("Loading new configuration file from " + configPath);
+ LOG.info("Loading new configuration file from " + configPath + routingDiff);
retryingExec("/usr/bin/sudo /opt/vespa/bin/vespa-reload-nginx");
metric.add(OK_CONFIG_RELOADS_METRIC, 1, null);
metric.set(GENERATED_UPSTREAMS_METRIC, upstreamCount, null);
}
+ private String getDiff(Path configPath, Path tempConfigPath) throws IOException {
+ Pair<Integer, String> executed = processExecuter.exec("diff -U1 " + configPath + " " + tempConfigPath);
+ return executed.getSecond();
+ }
+
/** Remove old config files */
private void gcConfig() throws IOException {
Instant oneWeekAgo = clock.instant().minus(Duration.ofDays(7));
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxConfig.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxConfig.java
index ffaa2b0bb60..93c5c6b27ed 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxConfig.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxConfig.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.routing.nginx;
import com.yahoo.vespa.hosted.routing.RoutingTable;
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxHealthClient.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxHealthClient.java
index c5634c396aa..3c64c6fc5d3 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxHealthClient.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxHealthClient.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.routing.nginx;
import com.yahoo.component.AbstractComponent;
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxMetricsReporter.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxMetricsReporter.java
index e5727955005..93ea68e0154 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxMetricsReporter.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxMetricsReporter.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.routing.nginx;
import com.google.common.collect.ImmutableMap;
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxPath.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxPath.java
index 0cde7725260..9d39969cf4c 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxPath.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/nginx/NginxPath.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.routing.nginx;
import java.nio.file.FileSystem;
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/restapi/AkamaiHandler.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/restapi/AkamaiHandler.java
index 9ed05278331..c3e9666adb6 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/restapi/AkamaiHandler.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/restapi/AkamaiHandler.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.routing.restapi;
import com.yahoo.component.annotation.Inject;
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/restapi/package-info.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/restapi/package-info.java
index 6a1d7f8234e..9f1476915e6 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/restapi/package-info.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/restapi/package-info.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
* @author mpolden
*/
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/HealthStatus.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/HealthStatus.java
index 11dbe0bc816..816314f8c70 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/HealthStatus.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/HealthStatus.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.routing.status;
/**
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/RoutingStatus.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/RoutingStatus.java
index 9c030aeb100..f74687514c2 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/RoutingStatus.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/RoutingStatus.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.routing.status;
/**
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/RoutingStatusClient.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/RoutingStatusClient.java
index d982bb06f32..b42df869dfa 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/RoutingStatusClient.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/RoutingStatusClient.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.routing.status;
import com.yahoo.component.annotation.Inject;
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/ServerGroup.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/ServerGroup.java
index 1ce73d7de58..dc5d46d57cb 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/ServerGroup.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/ServerGroup.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.routing.status;
import java.util.Collections;
diff --git a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/package-info.java b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/package-info.java
index 2cd9e6a141e..df34aeec8f1 100644
--- a/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/package-info.java
+++ b/routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/package-info.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
* @author mpolden
*/