Skip to content

Commit

Permalink
Fix for health check handling in case of client timeouts (#14)
Browse files Browse the repository at this point in the history
* fix: fixed health check error handling

* fix: fixed typo in picker.go
  • Loading branch information
WRichter72 authored Sep 2, 2024
1 parent 01712d7 commit b838294
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ func CheckConsumerHealth(hcData *PreparedHealthCheckData, subscription *resource

resp, err := executeHealthRequestWithToken(hcData.HealthCheckEntry.CallbackUrl, hcData.HealthCheckEntry.Method, subscription, token)
if err != nil {
log.Error().Err(err).Msgf("Failed to perform http-request for callback-url %s", hcData.HealthCheckEntry.CallbackUrl)
log.Info().Err(err).Msgf("Failed to perform http-request for callback-url %s", hcData.HealthCheckEntry.CallbackUrl)
updateHealthCheckEntry(hcData.Ctx, hcData.HealthCheckKey, hcData.HealthCheckEntry, 0)
return err
}
log.Debug().Msgf("Received response for callback-url %s with http-status: %v", hcData.HealthCheckEntry.CallbackUrl, resp.StatusCode)
Expand Down Expand Up @@ -150,7 +151,7 @@ func PrepareHealthCheck(subscription *resource.SubscriptionResource) (*PreparedH

// Attempt to acquire a lock for the health check key
//isAcquired, _ := cache.HealthCheckCache.TryLockWithTimeout(ctx, healthCheckKey, 10*time.Millisecond)
isAcquired, _ := cache.HealthCheckCache.TryLockWithLeaseAndTimeout(ctx, healthCheckKey, 30000*time.Millisecond, 10*time.Millisecond)
isAcquired, _ := cache.HealthCheckCache.TryLockWithLeaseAndTimeout(ctx, healthCheckKey, 60000*time.Millisecond, 10*time.Millisecond)

castedHealthCheckEntry := healthCheckEntry.(HealthCheckCacheEntry)
return &PreparedHealthCheckData{Ctx: ctx, HealthCheckKey: healthCheckKey, HealthCheckEntry: castedHealthCheckEntry, IsAcquired: isAcquired}, nil
Expand Down

0 comments on commit b838294

Please sign in to comment.