Skip to content

Commit

Permalink
feat(discovery): refactor to use shared discovery abstraction from ko…
Browse files Browse the repository at this point in the history
…rk-core (#814)
  • Loading branch information
cfieber authored Jul 10, 2020
1 parent 23bc829 commit 5c8b0b6
Show file tree
Hide file tree
Showing 22 changed files with 88 additions and 174 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fiatVersion=1.21.0
korkVersion=7.50.0
korkVersion=7.51.2
org.gradle.parallel=true
spinnakerGradleVersion=8.3.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@

import static java.lang.String.format;

import com.netflix.appinfo.InstanceInfo.InstanceStatus;
import com.netflix.discovery.DiscoveryClient;
import com.netflix.spectator.api.Id;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.igor.IgorConfigurationProperties;
import com.netflix.spinnaker.kork.discovery.DiscoveryStatusListener;
import com.netflix.spinnaker.kork.discovery.RemoteStatusChangedEvent;
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService;
import com.netflix.spinnaker.kork.eureka.RemoteStatusChangedEvent;
import java.time.Duration;
import java.util.Optional;
import java.util.concurrent.ScheduledFuture;
Expand All @@ -43,7 +42,7 @@ public abstract class CommonPollingMonitor<I extends DeltaItem, T extends Pollin
protected final IgorConfigurationProperties igorProperties;
protected final Registry registry;
protected final Id missedNotificationId;
private final Optional<DiscoveryClient> discoveryClient;
private final DiscoveryStatusListener discoveryStatusListener;
private final AtomicLong lastPoll = new AtomicLong();
private final Id itemsCachedId;
private final Id itemsOverThresholdId;
Expand All @@ -59,13 +58,13 @@ public CommonPollingMonitor(
IgorConfigurationProperties igorProperties,
Registry registry,
DynamicConfigService dynamicConfigService,
Optional<DiscoveryClient> discoveryClient,
DiscoveryStatusListener discoveryStatusListener,
Optional<LockService> lockService,
TaskScheduler scheduler) {
this.igorProperties = igorProperties;
this.registry = registry;
this.dynamicConfigService = dynamicConfigService;
this.discoveryClient = discoveryClient;
this.discoveryStatusListener = discoveryStatusListener;
this.lockService = lockService;
this.scheduler = scheduler;

Expand Down Expand Up @@ -238,14 +237,7 @@ public boolean isInService() {
return false;
}

if (discoveryClient.isPresent()) {
InstanceStatus remoteStatus = discoveryClient.get().getInstanceRemoteStatus();
log.info("current remote status {}", remoteStatus);
return remoteStatus == InstanceStatus.UP;
}

log.info("no DiscoveryClient, assuming InService");
return true;
return discoveryStatusListener.isEnabled();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.netflix.spinnaker.igor.polling;

import com.netflix.spinnaker.kork.eureka.RemoteStatusChangedEvent;
import com.netflix.spinnaker.kork.discovery.RemoteStatusChangedEvent;
import org.springframework.context.ApplicationListener;

public interface PollingMonitor extends ApplicationListener<RemoteStatusChangedEvent> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static java.util.Collections.emptyList;
import static org.jfrog.artifactory.client.aql.AqlItem.aqlItem;

import com.netflix.discovery.DiscoveryClient;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.igor.IgorConfigurationProperties;
import com.netflix.spinnaker.igor.artifactory.model.ArtifactoryItem;
Expand All @@ -34,6 +33,7 @@
import com.netflix.spinnaker.igor.polling.PollContext;
import com.netflix.spinnaker.igor.polling.PollingDelta;
import com.netflix.spinnaker.kork.artifacts.model.Artifact;
import com.netflix.spinnaker.kork.discovery.DiscoveryStatusListener;
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService;
import com.netflix.spinnaker.security.AuthenticatedRequest;
import java.io.IOException;
Expand Down Expand Up @@ -71,13 +71,19 @@ public ArtifactoryBuildMonitor(
IgorConfigurationProperties properties,
Registry registry,
DynamicConfigService dynamicConfigService,
Optional<DiscoveryClient> discoveryClient,
DiscoveryStatusListener discoveryStatusListener,
Optional<LockService> lockService,
Optional<EchoService> echoService,
ArtifactoryCache cache,
ArtifactoryProperties artifactoryProperties,
TaskScheduler scheduler) {
super(properties, registry, dynamicConfigService, discoveryClient, lockService, scheduler);
super(
properties,
registry,
dynamicConfigService,
discoveryStatusListener,
lockService,
scheduler);
this.cache = cache;
this.artifactoryProperties = artifactoryProperties;
this.echoService = echoService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.netflix.spinnaker.igor.artifactory.model.ArtifactorySearch
import com.netflix.spinnaker.igor.config.ArtifactoryProperties
import com.netflix.spinnaker.igor.history.EchoService
import com.netflix.spinnaker.igor.polling.LockService
import com.netflix.spinnaker.kork.discovery.DiscoveryStatusListener
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService
import com.squareup.okhttp.mockwebserver.MockResponse
import com.squareup.okhttp.mockwebserver.MockWebServer
Expand All @@ -43,7 +44,7 @@ class ArtifactoryBuildMonitorSpec extends Specification {
igorConfigurationProperties,
new NoopRegistry(),
new DynamicConfigService.NoopDynamicConfig(),
Optional.empty(),
new DiscoveryStatusListener(true),
Optional.ofNullable(lockService),
Optional.of(echoService),
cache,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package com.netflix.spinnaker.igor.plugins;

import com.netflix.discovery.DiscoveryClient;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.igor.IgorConfigurationProperties;
import com.netflix.spinnaker.igor.history.EchoService;
Expand All @@ -28,6 +27,7 @@
import com.netflix.spinnaker.igor.polling.LockService;
import com.netflix.spinnaker.igor.polling.PollContext;
import com.netflix.spinnaker.igor.polling.PollingDelta;
import com.netflix.spinnaker.kork.discovery.DiscoveryStatusListener;
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService;
import com.netflix.spinnaker.security.AuthenticatedRequest;
import java.time.Instant;
Expand All @@ -50,13 +50,19 @@ public PluginsBuildMonitor(
IgorConfigurationProperties igorProperties,
Registry registry,
DynamicConfigService dynamicConfigService,
Optional<DiscoveryClient> discoveryClient,
DiscoveryStatusListener discoveryStatusListener,
Optional<LockService> lockService,
PluginReleaseService pluginInfoService,
PluginCache cache,
Optional<EchoService> echoService,
TaskScheduler scheduler) {
super(igorProperties, registry, dynamicConfigService, discoveryClient, lockService, scheduler);
super(
igorProperties,
registry,
dynamicConfigService,
discoveryStatusListener,
lockService,
scheduler);
this.pluginInfoService = pluginInfoService;
this.cache = cache;
this.echoService = echoService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import static net.logstash.logback.argument.StructuredArguments.kv;

import com.netflix.discovery.DiscoveryClient;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.igor.IgorConfigurationProperties;
import com.netflix.spinnaker.igor.build.BuildCache;
Expand All @@ -39,6 +38,7 @@
import com.netflix.spinnaker.igor.travis.client.model.v3.V3Build;
import com.netflix.spinnaker.igor.travis.config.TravisProperties;
import com.netflix.spinnaker.igor.travis.service.TravisService;
import com.netflix.spinnaker.kork.discovery.DiscoveryStatusListener;
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService;
import com.netflix.spinnaker.security.AuthenticatedRequest;
import java.time.Duration;
Expand Down Expand Up @@ -75,14 +75,20 @@ public TravisBuildMonitor(
IgorConfigurationProperties properties,
Registry registry,
DynamicConfigService dynamicConfigService,
Optional<DiscoveryClient> discoveryClient,
DiscoveryStatusListener discoveryStatusListener,
BuildCache buildCache,
BuildServices buildServices,
TravisProperties travisProperties,
Optional<EchoService> echoService,
Optional<LockService> lockService,
TaskScheduler scheduler) {
super(properties, registry, dynamicConfigService, discoveryClient, lockService, scheduler);
super(
properties,
registry,
dynamicConfigService,
discoveryStatusListener,
lockService,
scheduler);
this.buildCache = buildCache;
this.buildServices = buildServices;
this.travisProperties = travisProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.netflix.spinnaker.igor.travis.client.model.v3.V3Repository
import com.netflix.spinnaker.igor.travis.config.TravisProperties
import com.netflix.spinnaker.igor.travis.service.TravisBuildConverter
import com.netflix.spinnaker.igor.travis.service.TravisService
import com.netflix.spinnaker.kork.discovery.DiscoveryStatusListener
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService
import org.springframework.scheduling.TaskScheduler
import spock.lang.Specification
Expand All @@ -51,7 +52,7 @@ class TravisBuildMonitorSpec extends Specification {
new IgorConfigurationProperties(),
new NoopRegistry(),
new DynamicConfigService.NoopDynamicConfig(),
Optional.empty(),
new DiscoveryStatusListener(true),
buildCache,
buildServices,
travisProperties,
Expand Down
2 changes: 1 addition & 1 deletion igor-web/igor-web.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ dependencies {
implementation "com.netflix.spinnaker.kork:kork-telemetry"
implementation "com.netflix.spinnaker.kork:kork-plugins"

implementation "com.netflix.eureka:eureka-client"
implementation "io.github.resilience4j:resilience4j-retry"

implementation "io.projectreactor:reactor-core"
implementation "com.google.code.gson:gson"
implementation "com.google.guava:guava"
implementation "javax.inject:javax.inject:1"

runtimeOnly "com.netflix.spinnaker.kork:kork-runtime"

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.netflix.spinnaker.igor.config;

import com.jakewharton.retrofit.Ok3Client;
import com.netflix.discovery.DiscoveryClient;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.config.DefaultServiceEndpoint;
import com.netflix.spinnaker.config.okhttp3.OkHttpClientProvider;
Expand All @@ -29,6 +28,7 @@
import com.netflix.spinnaker.igor.plugins.front50.Front50Service;
import com.netflix.spinnaker.igor.plugins.front50.PluginReleaseService;
import com.netflix.spinnaker.igor.polling.LockService;
import com.netflix.spinnaker.kork.discovery.DiscoveryStatusListener;
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService;
import com.netflix.spinnaker.kork.jedis.RedisClientDelegate;
import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger;
Expand Down Expand Up @@ -74,7 +74,7 @@ public PluginsBuildMonitor pluginsBuildMonitor(
IgorConfigurationProperties properties,
Registry registry,
DynamicConfigService dynamicConfigService,
Optional<DiscoveryClient> discoveryClient,
DiscoveryStatusListener discoveryStatusListener,
Optional<LockService> lockService,
PluginReleaseService pluginReleaseService,
PluginCache pluginCache,
Expand All @@ -84,7 +84,7 @@ public PluginsBuildMonitor pluginsBuildMonitor(
properties,
registry,
dynamicConfigService,
discoveryClient,
discoveryStatusListener,
lockService,
pluginReleaseService,
pluginCache,
Expand Down
Loading

0 comments on commit 5c8b0b6

Please sign in to comment.