From 4b8bcc0d3ff5d849cf69df80274378b11fc79c35 Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Wed, 27 May 2020 14:40:20 +0200 Subject: Add SystemMonitor and report to it from VersionStatusUpdater --- .../maintenance/VersionStatusUpdater.java | 24 ++++++++++++++++++++-- .../integration/ServiceRegistryMock.java | 8 ++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) (limited to 'controller-server') diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/VersionStatusUpdater.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/VersionStatusUpdater.java index 4f1f453637e..214c3c4b48f 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/VersionStatusUpdater.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/VersionStatusUpdater.java @@ -1,17 +1,23 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.maintenance; -import com.yahoo.concurrent.maintenance.JobControl; import com.yahoo.vespa.hosted.controller.Controller; +import com.yahoo.vespa.hosted.controller.api.integration.organization.SystemMonitor; import com.yahoo.vespa.hosted.controller.versions.VersionStatus; +import com.yahoo.vespa.hosted.controller.versions.VespaVersion; import com.yahoo.yolean.Exceptions; import java.time.Duration; import java.util.logging.Level; +import static com.yahoo.vespa.hosted.controller.api.integration.organization.SystemMonitor.Confidence.broken; +import static com.yahoo.vespa.hosted.controller.api.integration.organization.SystemMonitor.Confidence.high; +import static com.yahoo.vespa.hosted.controller.api.integration.organization.SystemMonitor.Confidence.low; +import static com.yahoo.vespa.hosted.controller.api.integration.organization.SystemMonitor.Confidence.normal; + /** * This maintenance job periodically updates the version status. - * Since the version status is expensive to compute and do not need to be perfectly up to date, + * Since the version status is expensive to compute and does not need to be perfectly up to date, * we do not want to recompute it each time it is accessed. * * @author bratseth @@ -27,10 +33,24 @@ public class VersionStatusUpdater extends ControllerMaintainer { try { VersionStatus newStatus = VersionStatus.compute(controller()); controller().updateVersionStatus(newStatus); + newStatus.systemVersion().ifPresent(version -> { + controller().serviceRegistry().systemMonitor().reportSystemVersion(version.versionNumber(), + convert(version.confidence())); + }); } catch (Exception e) { log.log(Level.WARNING, "Failed to compute version status: " + Exceptions.toMessageString(e) + ". Retrying in " + interval()); } } + private static SystemMonitor.Confidence convert(VespaVersion.Confidence confidence) { + switch (confidence) { + case broken: return broken; + case low: return low; + case normal: return normal; + case high: return high; + default: throw new IllegalArgumentException("Unexpected confidence '" + confidence + "'"); + } + } + } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java index 667e9687aa1..debbf2a8315 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java @@ -19,10 +19,12 @@ import com.yahoo.vespa.hosted.controller.api.integration.entity.MemoryEntityServ import com.yahoo.vespa.hosted.controller.api.integration.organization.MockBilling; import com.yahoo.vespa.hosted.controller.api.integration.organization.MockContactRetriever; import com.yahoo.vespa.hosted.controller.api.integration.organization.MockIssueHandler; +import com.yahoo.vespa.hosted.controller.api.integration.organization.SystemMonitor; import com.yahoo.vespa.hosted.controller.api.integration.resource.CostReportConsumerMock; import com.yahoo.vespa.hosted.controller.api.integration.routing.GlobalRoutingService; import com.yahoo.vespa.hosted.controller.api.integration.routing.MemoryGlobalRoutingService; import com.yahoo.vespa.hosted.controller.api.integration.stubs.DummyOwnershipIssues; +import com.yahoo.vespa.hosted.controller.api.integration.stubs.DummySystemMonitor; import com.yahoo.vespa.hosted.controller.api.integration.stubs.LoggingDeploymentIssues; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMailer; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMeteringClient; @@ -49,6 +51,7 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg private final DummyOwnershipIssues dummyOwnershipIssues = new DummyOwnershipIssues(); private final LoggingDeploymentIssues loggingDeploymentIssues = new LoggingDeploymentIssues(); private final MemoryEntityService memoryEntityService = new MemoryEntityService(); + private final DummySystemMonitor systemMonitor = new DummySystemMonitor(); private final CostReportConsumerMock costReportConsumerMock = new CostReportConsumerMock(); private final MockBilling mockBilling = new MockBilling(); private final MockAwsEventFetcher mockAwsEventFetcher = new MockAwsEventFetcher(); @@ -184,6 +187,11 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg return applicationRoleService; } + @Override + public DummySystemMonitor systemMonitor() { + return systemMonitor; + } + public ConfigServerMock configServerMock() { return configServerMock; } -- cgit v1.2.3