diff options
author | Valerij Fredriksen <freva@users.noreply.github.com> | 2020-03-21 09:13:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-21 09:13:33 +0100 |
commit | de5ac882cd07205b1aaaa045763694ff718b614f (patch) | |
tree | 06e2b40f8f2b01e04549b8891fbd60027cd85c02 /orchestrator/src/main | |
parent | a5912471ffcaad78e83b950b8ad2bb16bb9c2b41 (diff) | |
parent | 583437679933b94f58467b40ead155f3db325c65 (diff) |
Merge pull request #12520 from vespa-engine/hakonhall/always-do-status-service-cleanup
Always do status service cleanup
Diffstat (limited to 'orchestrator/src/main')
-rw-r--r-- | orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZkStatusService.java | 50 |
1 files changed, 19 insertions, 31 deletions
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZkStatusService.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZkStatusService.java index 3bf0d886a41..fab58aaf638 100644 --- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZkStatusService.java +++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZkStatusService.java @@ -47,7 +47,6 @@ public class ZkStatusService implements StatusService { private final HostInfosCache hostInfosCache; private final Metric metric; private final Timer timer; - private final boolean doCleanup; private final AntiServiceMonitor antiServiceMonitor; /** @@ -61,24 +60,21 @@ public class ZkStatusService implements StatusService { @Component Curator curator, @Component Metric metric, @Component Timer timer, - @Component FlagSource flagSource, @Component AntiServiceMonitor antiServiceMonitor) { this(curator, metric, timer, new HostInfosCache(curator, new HostInfosServiceImpl(curator, timer)), - Flags.CLEANUP_STATUS_SERVICE.bindTo(flagSource).value(), antiServiceMonitor); } /** Non-private for testing only. */ ZkStatusService(Curator curator, Metric metric, Timer timer, HostInfosCache hostInfosCache, - boolean doCleanup, AntiServiceMonitor antiServiceMonitor) { + AntiServiceMonitor antiServiceMonitor) { this.curator = curator; this.metric = metric; this.timer = timer; this.hostInfosCache = hostInfosCache; - this.doCleanup = doCleanup; this.antiServiceMonitor = antiServiceMonitor; } @@ -241,19 +237,15 @@ public class ZkStatusService implements StatusService { */ @Override public void onApplicationActivate(ApplicationInstanceReference reference, Set<HostName> hostnames) { - if (doCleanup) { - withLockForAdminOp(reference, " was activated", () -> { - HostInfos hostInfos = hostInfosCache.getCachedHostInfos(reference); - Set<HostName> toRemove = new HashSet<>(hostInfos.getZkHostnames()); - toRemove.removeAll(hostnames); - if (toRemove.size() > 0) { - log.log(LogLevel.INFO, "Removing " + toRemove + " of " + reference + " from status service"); - hostInfosCache.removeHosts(reference, toRemove); - } - }); - } else { - log.log(LogLevel.INFO, "Would have removed orphaned hosts of " + reference + " from status service"); - } + withLockForAdminOp(reference, " was activated", () -> { + HostInfos hostInfos = hostInfosCache.getCachedHostInfos(reference); + Set<HostName> toRemove = new HashSet<>(hostInfos.getZkHostnames()); + toRemove.removeAll(hostnames); + if (toRemove.size() > 0) { + log.log(LogLevel.INFO, "Removing " + toRemove + " of " + reference + " from status service"); + hostInfosCache.removeHosts(reference, toRemove); + } + }); } /** @@ -267,22 +259,18 @@ public class ZkStatusService implements StatusService { */ @Override public void onApplicationRemove(ApplicationInstanceReference reference) { - if (doCleanup) { - withLockForAdminOp(reference, " was removed", () -> { - log.log(LogLevel.INFO, "Removing application " + reference + " from status service"); + withLockForAdminOp(reference, " was removed", () -> { + log.log(LogLevel.INFO, "Removing application " + reference + " from status service"); - // /vespa/application-status-service/REFERENCE - curator.delete(Path.fromString(applicationInstanceSuspendedPath(reference))); + // /vespa/application-status-service/REFERENCE + curator.delete(Path.fromString(applicationInstanceSuspendedPath(reference))); - // /vespa/host-status-service/REFERENCE/hosts-allowed-down - curator.delete(Path.fromString(hostsAllowedDownPath(reference))); + // /vespa/host-status-service/REFERENCE/hosts-allowed-down + curator.delete(Path.fromString(hostsAllowedDownPath(reference))); - // /vespa/host-status/APPLICATION_ID - hostInfosCache.removeApplication(reference); - }); - } else { - log.log(LogLevel.INFO, "Would have removed application " + reference + " from status service"); - } + // /vespa/host-status/APPLICATION_ID + hostInfosCache.removeApplication(reference); + }); } private void withLockForAdminOp(ApplicationInstanceReference reference, |