summaryrefslogtreecommitdiffstats
path: root/routing-generator
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2022-06-09 10:57:53 +0200
committerMartin Polden <mpolden@mpolden.no>2022-06-13 10:47:53 +0200
commite046617cd9b30fa4fc2cf1fd472cc40de19d3e13 (patch)
treeb256a24824959c0d478f8fdf6b8773306c64a1b7 /routing-generator
parentd2f5c29433bd1b1cdea67b78af7e3c59a5341c14 (diff)
Remove special handling of upstream name
Diffstat (limited to 'routing-generator')
-rw-r--r--routing-generator/src/main/java/com/yahoo/vespa/hosted/routing/status/ServerGroup.java9
-rw-r--r--routing-generator/src/test/java/com/yahoo/vespa/hosted/routing/nginx/NginxHealthClientTest.java7
-rw-r--r--routing-generator/src/test/resources/nginx-health-output-all-down.json4
-rw-r--r--routing-generator/src/test/resources/nginx-health-output-stream.json12
-rw-r--r--routing-generator/src/test/resources/nginx-health-output.json4
5 files changed, 4 insertions, 32 deletions
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 f1a87aa7106..1ce73d7de58 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,14 +1,13 @@
// Copyright Yahoo. 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.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
- * A group servers behind a router/reverse proxy.
+ * A group of servers behind a router/reverse proxy.
*
* @author mpolden
*/
@@ -29,11 +28,7 @@ public class ServerGroup {
/** Returns whether given upstream is healthy */
public boolean isHealthy(String upstreamName) {
- // TODO(mpolden): Look up key directly here once layer 4 config (and thus "-feed" upstreams) are gone
- List<Server> upstreamServers = servers.values().stream()
- .flatMap(Collection::stream)
- .filter(server -> upstreamName.startsWith(server.upstreamName()))
- .collect(Collectors.toList());
+ List<Server> upstreamServers = servers.getOrDefault(upstreamName, List.of());
long upCount = upstreamServers.stream()
.filter(Server::up)
.count();
diff --git a/routing-generator/src/test/java/com/yahoo/vespa/hosted/routing/nginx/NginxHealthClientTest.java b/routing-generator/src/test/java/com/yahoo/vespa/hosted/routing/nginx/NginxHealthClientTest.java
index 722bc55437f..24b5301d55b 100644
--- a/routing-generator/src/test/java/com/yahoo/vespa/hosted/routing/nginx/NginxHealthClientTest.java
+++ b/routing-generator/src/test/java/com/yahoo/vespa/hosted/routing/nginx/NginxHealthClientTest.java
@@ -52,13 +52,6 @@ public class NginxHealthClientTest {
assertFalse(service.servers().isHealthy("frog.prod.music.vespa.us-east-2.prod"));
}
- @Test
- public void all_up_but_other_endpoint_down_stream() {
- NginxHealthClient service = createClient("nginx-health-output-stream.json");
- assertTrue(service.servers().isHealthy("gateway.prod.music.vespa.us-east-2.prod"));
- assertFalse(service.servers().isHealthy("frog.prod.music.vespa.us-east-2.prod"));
- }
-
private static NginxHealthClient createClient(String file) {
HttpClientMock httpClient = new HttpClientMock().setResponse("GET",
"http://localhost:4080/health-status/?format=json",
diff --git a/routing-generator/src/test/resources/nginx-health-output-all-down.json b/routing-generator/src/test/resources/nginx-health-output-all-down.json
index c79b977fa99..c9b68d66b58 100644
--- a/routing-generator/src/test/resources/nginx-health-output-all-down.json
+++ b/routing-generator/src/test/resources/nginx-health-output-all-down.json
@@ -5,8 +5,6 @@
"http": [],
"stream": [
{"index": 0, "upstream": "gateway.prod.music.vespa.us-east-2.prod", "name": "10.78.114.166:4080", "status": "down", "rise": 0, "fall": 1, "type": "http", "port": 0},
- {"index": 1, "upstream": "gateway.prod.music.vespa.us-east-2.prod", "name": "10.78.115.68:4080", "status": "down", "rise": 2, "fall": 0, "type": "http", "port": 0},
- {"index": 2, "upstream": "gateway.prod.music.vespa.us-east-2.prod-feed", "name": "10.78.114.166:4080", "status": "down", "rise": 0, "fall": 1, "type": "http", "port": 0},
- {"index": 3, "upstream": "gateway.prod.music.vespa.us-east-2.prod-feed", "name": "10.78.115.68:4080", "status": "down", "rise": 1, "fall": 0, "type": "http", "port": 0}
+ {"index": 1, "upstream": "gateway.prod.music.vespa.us-east-2.prod", "name": "10.78.115.68:4080", "status": "down", "rise": 2, "fall": 0, "type": "http", "port": 0}
]
}}
diff --git a/routing-generator/src/test/resources/nginx-health-output-stream.json b/routing-generator/src/test/resources/nginx-health-output-stream.json
deleted file mode 100644
index 9439e3f1ac4..00000000000
--- a/routing-generator/src/test/resources/nginx-health-output-stream.json
+++ /dev/null
@@ -1,12 +0,0 @@
-
-{"servers": {
- "total": 4,
- "generation": 1,
- "http": [],
- "stream": [
- {"index": 0, "upstream": "gateway.prod.music.vespa.us-east-2.prod", "name": "10.78.114.166:4080", "status": "down", "rise": 0, "fall": 1, "type": "http", "port": 0},
- {"index": 1, "upstream": "gateway.prod.music.vespa.us-east-2.prod", "name": "10.78.115.68:4080", "status": "up", "rise": 2, "fall": 0, "type": "http", "port": 0},
- {"index": 2, "upstream": "gateway.prod.music.vespa.us-east-2.prod-feed", "name": "10.78.114.166:4080", "status": "down", "rise": 0, "fall": 1, "type": "http", "port": 0},
- {"index": 3, "upstream": "gateway.prod.music.vespa.us-east-2.prod-feed", "name": "10.78.115.68:4080", "status": "down", "rise": 1, "fall": 0, "type": "http", "port": 0}
- ]
-}}
diff --git a/routing-generator/src/test/resources/nginx-health-output.json b/routing-generator/src/test/resources/nginx-health-output.json
index 9439e3f1ac4..1ef9a330fa7 100644
--- a/routing-generator/src/test/resources/nginx-health-output.json
+++ b/routing-generator/src/test/resources/nginx-health-output.json
@@ -5,8 +5,6 @@
"http": [],
"stream": [
{"index": 0, "upstream": "gateway.prod.music.vespa.us-east-2.prod", "name": "10.78.114.166:4080", "status": "down", "rise": 0, "fall": 1, "type": "http", "port": 0},
- {"index": 1, "upstream": "gateway.prod.music.vespa.us-east-2.prod", "name": "10.78.115.68:4080", "status": "up", "rise": 2, "fall": 0, "type": "http", "port": 0},
- {"index": 2, "upstream": "gateway.prod.music.vespa.us-east-2.prod-feed", "name": "10.78.114.166:4080", "status": "down", "rise": 0, "fall": 1, "type": "http", "port": 0},
- {"index": 3, "upstream": "gateway.prod.music.vespa.us-east-2.prod-feed", "name": "10.78.115.68:4080", "status": "down", "rise": 1, "fall": 0, "type": "http", "port": 0}
+ {"index": 1, "upstream": "gateway.prod.music.vespa.us-east-2.prod", "name": "10.78.115.68:4080", "status": "up", "rise": 2, "fall": 0, "type": "http", "port": 0}
]
}}