[cartservice] Increases health check timeout (#240)
* Increases cartservice health check rpc timeout * remove stopwatch from health check * cleanup * Cleanup
This commit is contained in:
parent
13b73067c4
commit
156dfcec8a
4 changed files with 13 additions and 15 deletions
|
@ -411,12 +411,12 @@ spec:
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
initialDelaySeconds: 15
|
initialDelaySeconds: 15
|
||||||
exec:
|
exec:
|
||||||
command: ["/bin/grpc_health_probe", "-addr=:7070"]
|
command: ["/bin/grpc_health_probe", "-addr=:7070", "-rpc-timeout=5s"]
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
initialDelaySeconds: 15
|
initialDelaySeconds: 15
|
||||||
periodSeconds: 10
|
periodSeconds: 10
|
||||||
exec:
|
exec:
|
||||||
command: ["/bin/grpc_health_probe", "-addr=:7070"]
|
command: ["/bin/grpc_health_probe", "-addr=:7070", "-rpc-timeout=5s"]
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
|
|
|
@ -15,7 +15,6 @@ namespace cartservice {
|
||||||
|
|
||||||
public override Task<HealthCheckResponse> Check(HealthCheckRequest request, ServerCallContext context){
|
public override Task<HealthCheckResponse> Check(HealthCheckRequest request, ServerCallContext context){
|
||||||
Console.WriteLine ("Checking CartService Health");
|
Console.WriteLine ("Checking CartService Health");
|
||||||
|
|
||||||
return Task.FromResult(new HealthCheckResponse {
|
return Task.FromResult(new HealthCheckResponse {
|
||||||
Status = dependency.Ping() ? HealthCheckResponse.Types.ServingStatus.Serving : HealthCheckResponse.Types.ServingStatus.NotServing
|
Status = dependency.Ping() ? HealthCheckResponse.Types.ServingStatus.Serving : HealthCheckResponse.Types.ServingStatus.NotServing
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<PackageReference Include="grpc.tools" Version="1.12.0" />
|
<PackageReference Include="grpc.tools" Version="1.12.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
|
||||||
<PackageReference Include="StackExchange.Redis" Version="1.2.6" />
|
<PackageReference Include="StackExchange.Redis" Version="2.0.601" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -45,13 +45,13 @@ namespace cartservice.cartstore
|
||||||
var cart = new Hipstershop.Cart();
|
var cart = new Hipstershop.Cart();
|
||||||
emptyCartBytes = cart.ToByteArray();
|
emptyCartBytes = cart.ToByteArray();
|
||||||
connectionString = $"{redisAddress},ssl=false,allowAdmin=true,connectRetry=5";
|
connectionString = $"{redisAddress},ssl=false,allowAdmin=true,connectRetry=5";
|
||||||
|
|
||||||
redisConnectionOptions = ConfigurationOptions.Parse(connectionString);
|
redisConnectionOptions = ConfigurationOptions.Parse(connectionString);
|
||||||
|
|
||||||
// Try to reconnect if first retry failed (up to 5 times with exponential backoff)
|
// Try to reconnect if first retry failed (up to 5 times with exponential backoff)
|
||||||
redisConnectionOptions.ConnectRetry = REDIS_RETRY_NUM;
|
redisConnectionOptions.ConnectRetry = REDIS_RETRY_NUM;
|
||||||
redisConnectionOptions.ReconnectRetryPolicy = new ExponentialRetry(100);
|
redisConnectionOptions.ReconnectRetryPolicy = new ExponentialRetry(100);
|
||||||
|
|
||||||
redisConnectionOptions.KeepAlive = 180;
|
redisConnectionOptions.KeepAlive = 180;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,11 +78,11 @@ namespace cartservice.cartstore
|
||||||
|
|
||||||
Console.WriteLine("Connecting to Redis: " + connectionString);
|
Console.WriteLine("Connecting to Redis: " + connectionString);
|
||||||
redis = ConnectionMultiplexer.Connect(redisConnectionOptions);
|
redis = ConnectionMultiplexer.Connect(redisConnectionOptions);
|
||||||
|
|
||||||
if (redis == null || !redis.IsConnected)
|
if (redis == null || !redis.IsConnected)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Wasn't able to connect to redis");
|
Console.WriteLine("Wasn't able to connect to redis");
|
||||||
|
|
||||||
// We weren't able to connect to redis despite 5 retries with exponential backoff
|
// We weren't able to connect to redis despite 5 retries with exponential backoff
|
||||||
throw new ApplicationException("Wasn't able to connect to redis");
|
throw new ApplicationException("Wasn't able to connect to redis");
|
||||||
}
|
}
|
||||||
|
@ -96,14 +96,14 @@ namespace cartservice.cartstore
|
||||||
Console.WriteLine($"Small test result: {res}");
|
Console.WriteLine($"Small test result: {res}");
|
||||||
|
|
||||||
redis.InternalError += (o, e) => { Console.WriteLine(e.Exception); };
|
redis.InternalError += (o, e) => { Console.WriteLine(e.Exception); };
|
||||||
redis.ConnectionRestored += (o, e) =>
|
redis.ConnectionRestored += (o, e) =>
|
||||||
{
|
{
|
||||||
isRedisConnectionOpened = true;
|
isRedisConnectionOpened = true;
|
||||||
Console.WriteLine("Connection to redis was retored successfully");
|
Console.WriteLine("Connection to redis was retored successfully");
|
||||||
};
|
};
|
||||||
redis.ConnectionFailed += (o, e) =>
|
redis.ConnectionFailed += (o, e) =>
|
||||||
{
|
{
|
||||||
Console.WriteLine("Connection failed. Disposing the object");
|
Console.WriteLine("Connection failed. Disposing the object");
|
||||||
isRedisConnectionOpened = false;
|
isRedisConnectionOpened = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -118,9 +118,9 @@ namespace cartservice.cartstore
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
EnsureRedisConnected();
|
EnsureRedisConnected();
|
||||||
|
|
||||||
var db = redis.GetDatabase();
|
var db = redis.GetDatabase();
|
||||||
|
|
||||||
// Access the cart from the cache
|
// Access the cart from the cache
|
||||||
var value = await db.HashGetAsync(userId, CART_FIELD_NAME);
|
var value = await db.HashGetAsync(userId, CART_FIELD_NAME);
|
||||||
|
|
||||||
|
@ -202,7 +202,6 @@ namespace cartservice.cartstore
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var redis = ConnectionMultiplexer.Connect(redisConnectionOptions);
|
|
||||||
var cache = redis.GetDatabase();
|
var cache = redis.GetDatabase();
|
||||||
var res = cache.Ping();
|
var res = cache.Ping();
|
||||||
return res != TimeSpan.Zero;
|
return res != TimeSpan.Zero;
|
||||||
|
|
Loading…
Reference in a new issue