LfsPluginAuthCommand: Don't spam error log when LFS plugin is missing

The LfsPluginAuthCommand is only installed when lfs.plugin is set in the
gerrit.config file. However, if the corresponding plugin is not actually
installed, or it does not provide the command implementation, Failure is
thrown which results in a stack trace being emitted to the log on every
ssh push operation.

Change it to throw UnloggedFailure, and write a less verbose message to
the log at warn level. This will still be emitted to the log on every
ssh push, but it's less noisy than before.

Change-Id: Ie638bda96ddbac173eccd74f9f6a25ed87c778c8
This commit is contained in:
David Pursehouse
2017-03-14 16:32:28 +09:00
parent 03ee3f6130
commit 07d7f65fed

View File

@@ -24,11 +24,18 @@ import com.google.inject.Provider;
import org.eclipse.jgit.lib.Config;
import org.kohsuke.args4j.Argument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
public class LfsPluginAuthCommand extends SshCommand {
private static final Logger log =
LoggerFactory.getLogger(LfsPluginAuthCommand.class);
private static final String CONFIGURATION_ERROR = "Server configuration error:"
+ " LFS auth over SSH is not properly configured.";
public interface LfsSshPluginAuth {
String authenticate(CurrentUser user, List<String> args)
throws UnloggedFailure, Failure;
@@ -65,11 +72,11 @@ public class LfsPluginAuthCommand extends SshCommand {
}
@Override
protected void run() throws UnloggedFailure, Failure, Exception {
protected void run() throws UnloggedFailure, Exception {
LfsSshPluginAuth pluginAuth = auth.get();
if (pluginAuth == null) {
throw new Failure(1, "Server configuration error:"
+ " LFS auth over SSH is not properly configured.");
log.warn(CONFIGURATION_ERROR);
throw new UnloggedFailure(1, CONFIGURATION_ERROR);
}
stdout.print(pluginAuth.authenticate(user.get(), args));