Skip to content

Commit

Permalink
fix(core): Remove the circular dependency on clouddriver (#234)
Browse files Browse the repository at this point in the history
This PR makes use of the locking support in `kork` and removes a
dependency on `clouddriver:cats-redis`.

Redis usage has migrated to the `RedisClientDelegate` which in theory
opens us up to using dynomite at Netflix.

BREAKING CHANGE

Introduces a new config fiat.writeMode.syncFailureDelayMs as a means
of controlling the lock delay on failure vs success of a sync. This was
previously managed by redis.poll.errorIntervalSeconds.
  • Loading branch information
ajordens authored Jun 18, 2018
1 parent c9e2fd8 commit 6635f01
Show file tree
Hide file tree
Showing 10 changed files with 241 additions and 288 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ allprojects {
apply plugin: 'groovy'

ext {
spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.157.3'
spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.157.9'
}

def checkLocalVersions = [spinnakerDependenciesVersion: spinnakerDependenciesVersion]
Expand Down
4 changes: 2 additions & 2 deletions fiat-roles/fiat-roles.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ dependencies {
compile spinnaker.dependency("bootActuator")
compile spinnaker.dependency("bootWeb")
compile spinnaker.dependency("korkHystrix")
// TODO(ttomsu): expose this in spinnaker-dependencies
compile "com.netflix.spinnaker.clouddriver:cats-redis:1.643.0"
compile spinnaker.dependency("korkJedis")
compile spinnaker.dependency("kork")

compile "redis.clients:jedis:${spinnaker.version('jedis')}"
compile "com.google.api-client:google-api-client:1.21.0"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2018 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.fiat.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.kork.jedis.RedisClientDelegate;
import com.netflix.spinnaker.kork.jedis.lock.RedisLockManager;
import com.netflix.spinnaker.kork.lock.LockManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Clock;
import java.util.Optional;

@Configuration
public class LockConfig {
@Bean
Clock clock() {
return Clock.systemDefaultZone();
}

@Bean
LockManager redisLockManager(Clock clock,
Registry registry,
ObjectMapper mapper,
RedisClientDelegate redisClientDelegate) {
return new RedisLockManager(
null, // will fall back to running node name
clock,
registry,
mapper,
redisClientDelegate,
Optional.empty(),
Optional.empty()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.netflix.spinnaker.fiat.config;

import com.netflix.spinnaker.cats.redis.JedisPoolSource;
import com.netflix.spinnaker.cats.redis.JedisSource;
import com.netflix.spinnaker.kork.jedis.JedisClientDelegate;
import com.netflix.spinnaker.kork.jedis.RedisClientDelegate;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
Expand All @@ -14,9 +14,7 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.Protocol;
import redis.clients.jedis.*;

import java.lang.reflect.Field;
import java.net.URI;
Expand All @@ -25,12 +23,6 @@
@Configuration
@ConditionalOnProperty("redis.connection")
public class RedisConfig {

@Bean
public JedisSource jedisSource(JedisPool jedisPool) {
return new JedisPoolSource(jedisPool);
}

@Bean
@ConfigurationProperties("redis")
public GenericObjectPoolConfig redisPoolConfig() {
Expand All @@ -48,6 +40,11 @@ public JedisPool jedisPool(@Value("${redis.connection:redis://localhost:6379}")
return createPool(redisPoolConfig, connection, timeout);
}

@Bean
RedisClientDelegate redisClientDelegate(JedisPool jedisPool) {
return new JedisClientDelegate(jedisPool);
}

private static JedisPool createPool(GenericObjectPoolConfig redisPoolConfig,
String connection,
int timeout) {
Expand Down
Loading

0 comments on commit 6635f01

Please sign in to comment.