Read about our upcoming Code of Conduct on this issue

Commit 839d3554 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

CommitService logging all incoming requests

In some cases this replaces existing logs with the more complete
dump of the request.

Again, it's not useful to put the name of the method in the message:
the name of the request class fulfills that purpose easily.
parent 06e62bed644b
Pipeline #23907 passed with stages
in 1 minute and 18 seconds
......@@ -97,6 +97,7 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
def CommitIsAncestor(self,
request: CommitIsAncestorRequest,
context) -> CommitIsAncestorResponse:
logger.debug("Processing %r", message.Logging(request))
# The question is legit for filtered changesets and that
# happens in MR rebase scenarios, before the Rails app realizes
# the MR has to be updated.
......@@ -126,7 +127,7 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
Actually, it always yields one response message, using the empty
response in case the given path does not resolve.
"""
logger.info("TreeEntry request=%r", message.Logging(request))
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context).unfiltered()
changeset = gitlab_revision_changeset(repo, request.revision)
if changeset is None:
......@@ -236,6 +237,7 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
TODO: find out if there are default values to apply for ``from`` and
``to``
"""
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
unfi = repo.unfiltered()
rev_from = gitlab_revision_changeset(repo, getattr(request, 'from'))
......@@ -261,6 +263,7 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
def CountCommits(self,
request: CountCommitsRequest,
context) -> CountCommitsResponse:
logger.debug("Processing %r", message.Logging(request))
# TODO: yet to finish this method to support all lookups
repo = self.load_repo(request.repository, context)
revision = request.revision
......@@ -304,6 +307,7 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
def CountDivergingCommits(self,
request: CountDivergingCommitsRequest,
context) -> CountDivergingCommitsResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
rev_from = gitlab_revision_changeset(repo, getattr(request, 'from'))
rev_to = gitlab_revision_changeset(repo, getattr(request, 'to'))
......@@ -336,7 +340,7 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
def GetTreeEntries(self, request: GetTreeEntriesRequest,
context) -> GetTreeEntriesResponse:
logger.info("GetTreeEntries request=%r", message.Logging(request))
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context).unfiltered()
revision = request.revision
changeset = gitlab_revision_changeset(repo, revision)
......@@ -374,9 +378,9 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
def ListFiles(self, request: ListFilesRequest,
context) -> ListFilesResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
revision = pycompat.sysbytes(request.revision)
logger.debug("ListFiles revision=%r", revision)
ctx = gitlab_revision_changeset(repo, revision)
if ctx is None:
return
......@@ -386,9 +390,9 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
def CommitStats(self, request: CommitStatsRequest,
context) -> CommitStatsResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
revision = pycompat.sysbytes(request.revision)
logger.debug("CommitStats revision=%r", revision)
ctx = gitlab_revision_changeset(repo, revision)
if ctx is None:
return internal_error(
......@@ -412,10 +416,9 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
def FindCommit(self,
request: FindCommitRequest, context) -> FindCommitResponse:
logger.debug("Request %r", message.Logging(request))
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
revision = request.revision
logger.debug("FindCommit revision=%r", revision)
ctx = gitlab_revision_changeset(repo, revision)
if ctx is None:
......@@ -429,13 +432,12 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
def FindAllCommits(self, request: FindAllCommitsRequest,
context) -> FindAllCommitsResponse:
logger.debug("Request %r", message.Logging(request))
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
revision = request.revision
opts = {}
if revision:
# If false, return all commits reachable by any branch in the repo
logger.debug("FindAllCommits revision=%r", revision)
ctx = gitlab_revision_changeset(repo, revision)
if ctx is None:
logger.debug(
......@@ -474,7 +476,8 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
context) -> FindCommitsResponse:
req_log = message.Logging(request)
logger.debug("Request %r", req_log)
logger.debug("Processing %r", message.Logging(request))
if request.limit == 0:
return
......@@ -521,6 +524,7 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
def RawBlame(self, request: RawBlameRequest,
context) -> RawBlameResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
filepath = request.path
if not filepath:
......@@ -538,15 +542,16 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
def LastCommitForPath(self,
request: LastCommitForPathRequest,
context) -> LastCommitForPathResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
revision, path = request.revision, request.path
logger.debug("LastCommitForPath revision=%r, path=%r", revision, path)
ctx = gitlab_revision_changeset(repo, revision)
changeset = latest_changeset_for_path(path, ctx)
return LastCommitForPathResponse(commit=message.commit(changeset))
def ListLastCommitsForTree(self, request: ListLastCommitsForTreeRequest,
context) -> ListLastCommitsForTreeResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
revision = pycompat.sysbytes(request.revision)
from_ctx = gitlab_revision_changeset(repo, revision)
......@@ -597,6 +602,7 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
def CommitsByMessage(self, request: CommitsByMessageRequest,
context) -> CommitsByMessageResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
query = request.query
if not query:
......@@ -638,6 +644,7 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
def ListCommitsByOid(self, request: ListCommitsByOidRequest,
context) -> ListCommitsByOidResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
lookup_error_classes = (error.LookupError, error.RepoLookupError)
for chunk in chunked(pycompat.sysbytes(oid) for oid in request.oid):
......@@ -666,6 +673,7 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
def ListCommitsByRefName(self, request: ListCommitsByRefNameRequest,
context) -> ListCommitsByRefNameResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
ref_names = request.ref_names
......@@ -701,6 +709,7 @@ class CommitServicer(CommitServiceServicer, HGitalyServicer):
def GetCommitMessages(self, request: GetCommitMessagesRequest,
context) -> GetCommitMessagesResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
results = {}
for commit_id in request.commit_ids:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment