Skip to content

Commit a11556b

Browse files
authored
Reduce logging frequency for GCS per project clients (#132429)
Log a message only when the client settings have actual changes. Relates: #131899
1 parent 7d2de6b commit a11556b

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

modules/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageService.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -364,25 +364,24 @@ public void applyClusterState(ClusterChangedEvent event) {
364364
// Skip project clients that have no credentials configured. This should not happen in serverless.
365365
// But it is safer to skip them and is also a more consistent behaviour with the cases when
366366
// project secrets are not present.
367-
final var clientSettings = allClientSettings.entrySet()
367+
final var clientSettingsWithCredentials = allClientSettings.entrySet()
368368
.stream()
369369
.filter(entry -> entry.getValue().getCredential() != null)
370370
.collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue));
371371

372-
if (allClientSettings.size() != clientSettings.size()) {
373-
logger.warn(
374-
"Project [{}] has [{}] GCS client settings, but [{}] is usable due to missing credentials for clients {}",
375-
project.id(),
376-
allClientSettings.size(),
377-
clientSettings.size(),
378-
Sets.difference(allClientSettings.keySet(), clientSettings.keySet())
379-
);
380-
}
381-
382372
// TODO: If performance is an issue, we may consider comparing just the relevant project secrets for new or updated clients
383373
// and avoid building the clientSettings
384-
if (newOrUpdated(project.id(), clientSettings)) {
385-
updatedPerProjectClients.put(project.id(), new PerProjectClientsHolder(clientSettings));
374+
if (newOrUpdated(project.id(), clientSettingsWithCredentials)) {
375+
if (allClientSettings.size() != clientSettingsWithCredentials.size()) {
376+
logger.warn(
377+
"Project [{}] has [{}] GCS client settings, but [{}] is usable due to missing credentials for clients {}",
378+
project.id(),
379+
allClientSettings.size(),
380+
clientSettingsWithCredentials.size(),
381+
Sets.difference(allClientSettings.keySet(), clientSettingsWithCredentials.keySet())
382+
);
383+
}
384+
updatedPerProjectClients.put(project.id(), new PerProjectClientsHolder(clientSettingsWithCredentials));
386385
}
387386
}
388387

0 commit comments

Comments
 (0)