diff options
Diffstat (limited to 'service-monitor/src')
3 files changed, 34 insertions, 3 deletions
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/health/ApplicationHealthMonitor.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/ApplicationHealthMonitor.java index 873baeae710..92f7afa121d 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/health/ApplicationHealthMonitor.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/ApplicationHealthMonitor.java @@ -81,7 +81,9 @@ class ApplicationHealthMonitor implements ServiceStatusProvider, AutoCloseable { @Override public void close() { - monitors.values().forEach(HealthMonitor::close); - monitors.clear(); + synchronized (guard) { + monitors.values().forEach(HealthMonitor::close); + monitors.clear(); + } } } diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthModel.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthModel.java index f015ecadbfc..9f51e0692a0 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthModel.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthModel.java @@ -14,9 +14,11 @@ import com.yahoo.vespa.service.monitor.ServiceId; import java.time.Duration; import java.util.Arrays; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * @author hakonhall @@ -67,7 +69,7 @@ public class StateV1HealthModel implements AutoCloseable { ServiceId serviceId = ApplicationInstanceGenerator.getServiceId(application, serviceInfo); for (PortInfo portInfo : serviceInfo.getPorts()) { - if (portInfo.getTags().containsAll(HTTP_HEALTH_PORT_TAGS)) { + if (portTaggedWith(portInfo, HTTP_HEALTH_PORT_TAGS)) { // The host-admin-in-zone-application is one big hack. int port = isNodeAdmin ? HostAdminApplication.HOST_ADMIN_HEALT_PORT : portInfo.getPort(); StateV1HealthEndpoint endpoint = new StateV1HealthEndpoint( @@ -88,6 +90,18 @@ public class StateV1HealthModel implements AutoCloseable { return endpoints; } + static boolean portTaggedWith(PortInfo portInfo, List<String> requiredTags) { + // vespa-model-inspect displays upper case tags, while actual tags for (at least) node-admin are lower case. + Collection<String> upperCasePortTags = portInfo.getTags().stream().map(String::toUpperCase).collect(Collectors.toSet()); + for (var tag : requiredTags) { + if (!upperCasePortTags.contains(tag.toUpperCase())) { + return false; + } + } + + return true; + } + @Override public void close() { executor.close(); diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/health/StateV1HealthModelTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/health/StateV1HealthModelTest.java index fcbc3cd9b9f..9803fb75423 100644 --- a/service-monitor/src/test/java/com/yahoo/vespa/service/health/StateV1HealthModelTest.java +++ b/service-monitor/src/test/java/com/yahoo/vespa/service/health/StateV1HealthModelTest.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.service.health; import com.yahoo.config.model.api.ApplicationInfo; +import com.yahoo.config.model.api.PortInfo; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.HostName; import com.yahoo.vespa.applicationmodel.ClusterId; @@ -23,7 +24,9 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -88,4 +91,16 @@ public class StateV1HealthModelTest { assertEquals(ZoneApplication.getNodeAdminClusterId(), serviceId.getClusterId()); assertEquals(ZoneApplication.getNodeAdminServiceType(), serviceId.getServiceType()); } + + @Test + public void caseInsensitiveTagMatching() { + PortInfo portInfo = mock(PortInfo.class); + when(portInfo.getTags()).thenReturn(List.of("http", "STATE", "foo")); + assertTrue(StateV1HealthModel.portTaggedWith(portInfo, StateV1HealthModel.HTTP_HEALTH_PORT_TAGS)); + assertTrue(StateV1HealthModel.portTaggedWith(portInfo, List.of("HTTP", "state"))); + + when(portInfo.getTags()).thenReturn(List.of("http", "foo")); + assertFalse(StateV1HealthModel.portTaggedWith(portInfo, StateV1HealthModel.HTTP_HEALTH_PORT_TAGS)); + assertFalse(StateV1HealthModel.portTaggedWith(portInfo, List.of("HTTP", "state"))); + } }
\ No newline at end of file |