diff --git a/fiat-roles/src/main/java/com/netflix/spinnaker/fiat/providers/internal/ClouddriverService.java b/fiat-roles/src/main/java/com/netflix/spinnaker/fiat/providers/internal/ClouddriverService.java index 1033856a2..169ca3426 100644 --- a/fiat-roles/src/main/java/com/netflix/spinnaker/fiat/providers/internal/ClouddriverService.java +++ b/fiat-roles/src/main/java/com/netflix/spinnaker/fiat/providers/internal/ClouddriverService.java @@ -72,7 +72,7 @@ public List getAccounts() { return accountCache.get(); }, (Throwable cause) -> { - log.warn("Falling back to account cache. Cause: " + cause.getMessage()); + logFallback("account", cause); List accounts = accountCache.get(); if (accounts == null) { throw new HystrixBadRequestException("Clouddriver is unavailable", cause); @@ -91,7 +91,7 @@ public List getApplications() { return applicationCache.get(); }, (Throwable cause) -> { - log.warn("Falling back to application cache. Cause: " + cause.getMessage()); + logFallback("application", cause); List applications = applicationCache.get(); if (applications == null) { throw new HystrixBadRequestException("Clouddriver is unavailable", cause); @@ -100,4 +100,9 @@ public List getApplications() { }) .execute(); } + + private static void logFallback(String resource, Throwable cause) { + String message = cause != null ? "Cause: " + cause.getMessage() : ""; + log.info("Falling back to {} cache. {}", resource, message); + } } diff --git a/fiat-roles/src/main/java/com/netflix/spinnaker/fiat/providers/internal/Front50Service.java b/fiat-roles/src/main/java/com/netflix/spinnaker/fiat/providers/internal/Front50Service.java index a1cb4bc56..1cd21068e 100644 --- a/fiat-roles/src/main/java/com/netflix/spinnaker/fiat/providers/internal/Front50Service.java +++ b/fiat-roles/src/main/java/com/netflix/spinnaker/fiat/providers/internal/Front50Service.java @@ -68,7 +68,7 @@ public List getAllApplicationPermissions() { return applicationCache.get(); }, (Throwable cause) -> { - log.warn("Falling back to application cache. Cause: " + cause.getMessage()); + logFallback("application", cause); List applications = applicationCache.get(); if (applications == null) { throw new HystrixBadRequestException("Front50 is unavailable", cause); @@ -87,7 +87,7 @@ public List getAllServiceAccounts() { return serviceAccountCache.get(); }, (Throwable cause) -> { - log.warn("Falling back to service account cache. Cause: " + cause.getMessage()); + logFallback("service account", cause); List serviceAccounts = serviceAccountCache.get(); if (serviceAccounts == null) { throw new HystrixBadRequestException("Front50 is unavailable", cause); @@ -95,4 +95,9 @@ public List getAllServiceAccounts() { return serviceAccounts; }).execute(); } + + private static void logFallback(String resource, Throwable cause) { + String message = cause != null ? "Cause: " + cause.getMessage() : ""; + log.info("Falling back to {} cache. {}", resource, message); + } }