Skip to content

Commit

Permalink
Merge pull request #2194 from dgoodwin/fatal-on-missing-redis
Browse files Browse the repository at this point in the history
Log fatal and exit on redis outage
  • Loading branch information
openshift-merge-bot[bot] authored Dec 20, 2024
2 parents 8a114fa + ab651fc commit 7ac645c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/api/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ func GetDataFromCacheOrGenerate[T any](
return defaultVal, []error{errors.WithMessagef(err, "failed to unmarshal cached item. cacheKey=%+v", cacheKey)}
}
return cr, nil
} else if strings.Contains(err.Error(), "connection refused") {
log.WithError(err).Fatalf("redis URL specified but got connection refused, exiting due to cost issues in this configuration")
}
log.WithFields(log.Fields{
"key": string(cacheKey),
Expand All @@ -99,6 +101,9 @@ func GetDataFromCacheOrGenerate[T any](
cr, err := json.Marshal(result)
if err == nil {
if err := c.Set(ctx, string(cacheKey), cr, cacheDuration); err != nil {
if strings.Contains(err.Error(), "connection refused") {
log.WithError(err).Fatalf("redis URL specified but got connection refused, exiting due to cost issues in this configuration")
}
log.WithError(err).Warningf("couldn't persist new item to cache")
} else {
log.Debugf("cache set for cache key: %s", string(cacheKey))
Expand Down

0 comments on commit 7ac645c

Please sign in to comment.