GUACAMOLE-2030: Show the Keeper notation warning only once.

This commit is contained in:
eugen-keeper committed 2025-07-22 13:23:25 +00:00
1 parent 1b73d49c7d
commit ffa8b2c336
2 files changed
+16 -13

No files matched your search

@@ -656,14 +656,17 @@ public class KsmClient {
// There is no way to differentiate if an error is caused by // There is no way to differentiate if an error is caused by
// a non-existing record or a pure parse failure. // a non-existing record or a pure parse failure.
catch (Error | Exception e) { catch (Error | Exception e) {
logger.warn("Keeper notation \"{}\" could not be resolved "
+ "to a record: {}", notation, e.getMessage());
logger.debug("Retrieval of record by Keeper notation failed.", e); logger.debug("Retrieval of record by Keeper notation failed.", e);
// If the secret is not found, invoke the fallback function // If the secret is not found, invoke the fallback function
if (fallbackFunction != null) if (fallbackFunction != null)
return fallbackFunction.get(); return fallbackFunction.get();
// Show the warning only if there is no fallback function
// and this was the last attempt
logger.warn("Keeper notation \"{}\" could not be resolved "
+ "to a record: {}", notation, e.getMessage());
return CompletableFuture.completedFuture(null); return CompletableFuture.completedFuture(null);
} }
finally { finally {
@@ -152,21 +152,21 @@ public class KsmSecretService implements VaultSecretService {
// Attempt to find a KSM config for this connection or group // Attempt to find a KSM config for this connection or group
String ksmConfig = getConnectionGroupKsmConfig(userContext, connectable); String ksmConfig = getConnectionGroupKsmConfig(userContext, connectable);
// Get the user-supplied KSM config, if allowed by config and
// set by the user
String userKsmConfig = getUserKSMConfig(userContext, connectable);
// If the user config is not defined or happens to be the same
// as admin-defined one, resolve without the fallback
if (userKsmConfig == null || Objects.equal(userKsmConfig, ksmConfig)) {
return getClient(ksmConfig).getSecret(name);
}
return getClient(ksmConfig).getSecret(name, new GuacamoleExceptionSupplier<Future<String>>() { return getClient(ksmConfig).getSecret(name, new GuacamoleExceptionSupplier<Future<String>>() {
@Override @Override
public Future<String> get() throws GuacamoleException { public Future<String> get() throws GuacamoleException {
return getClient(userKsmConfig).getSecret(name);
// Get the user-supplied KSM config, if allowed by config and
// set by the user
String userKsmConfig = getUserKSMConfig(userContext, connectable);
// If the user config happens to be the same as admin-defined one,
// don't bother trying again
if (userKsmConfig != null && !Objects.equal(userKsmConfig, ksmConfig))
return getClient(userKsmConfig).getSecret(name);
return CompletableFuture.completedFuture(null);
} }
}); });