Improve error logging on receive commits

Make sure that in all cases where a push is rejected with
"REJECTED_OTHER_REASON (internal server error)" or
"REJECTED_OTHER_REASON (internal error)" a log entry is written and
that this log entry contains the project name.

Change-Id: Ib04d1c4550f1511b1c83462147b9a2d7d8d7f51d
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin 2014-07-16 07:48:39 +02:00
parent 76490bb1d0
commit abac43518b
2 changed files with 11 additions and 3 deletions

View File

@ -163,7 +163,9 @@ public class AsyncReceiveCommits implements PreReceiveHook {
executor.submit(scopePropagator.wrap(new Worker(commands))),
timeoutMillis, TimeUnit.MILLISECONDS);
} catch (ExecutionException e) {
log.warn("Error in ReceiveCommits", e);
log.warn(String.format(
"Error in ReceiveCommits while processing changes for project %s",
rc.getProject().getName()), e);
rc.addError("internal error while processing changes " + e.getMessage());
// ReceiveCommits has tried its best to catch errors, so anything at this
// point is very bad.

View File

@ -721,6 +721,8 @@ public class ReceiveCommits {
}
} else if (replace.inputCommand.getResult() == NOT_ATTEMPTED) {
reject(replace.inputCommand, "internal server error");
log.error(String.format("Replacement for project %s was not attempted",
project.getName()));
}
}
@ -1719,14 +1721,18 @@ public class ReceiveCommits {
}
}
} catch (OrmException err) {
log.error("Cannot read database before replacement", err);
log.error(String.format(
"Cannot read database before replacement for project %s",
project.getName()), err);
for (ReplaceRequest req : replaceByChange.values()) {
if (req.inputCommand.getResult() == NOT_ATTEMPTED) {
req.inputCommand.setResult(REJECTED_OTHER_REASON, "internal server error");
}
}
} catch (IOException err) {
log.error("Cannot read repository before replacement", err);
log.error(String.format(
"Cannot read repository before replacement for project %s",
project.getName()), err);
for (ReplaceRequest req : replaceByChange.values()) {
if (req.inputCommand.getResult() == NOT_ATTEMPTED) {
req.inputCommand.setResult(REJECTED_OTHER_REASON, "internal server error");