Read about our upcoming Code of Conduct on this issue

Commit 06e62bed authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

RefService logging all incoming requests

We don't need to include the method name in the log message,
because of the Gitaly protocol conventions: each method has
its own, dedicated Request class, whose name is already part of
the rendering.
parent 13722000f132
......@@ -108,6 +108,7 @@
self,
request: FindDefaultBranchNameRequest,
context) -> FindDefaultBranchNameResponse:
logger.debug("Processing %r", message.Logging(request))
try:
repo = self.load_repo(request.repository, context)
except KeyError as exc:
......@@ -131,6 +132,7 @@
def FindAllBranchNames(self,
request: FindAllBranchNamesRequest,
context) -> FindAllBranchNamesResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
for chunk in chunked(iter_gitlab_branches_as_refs(repo)):
yield FindAllBranchNamesResponse(names=(br[0] for br in chunk))
......@@ -138,6 +140,7 @@
def FindAllTagNames(self,
request: FindAllTagNamesRequest,
context) -> FindAllTagNamesResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
# TODO SPEC it's not clear whether GitLab actually expect the
# tags to be in any ordering. At a quick glance it doesn't, but
......@@ -186,6 +189,7 @@
As of GitLab 12.10, there is no caller for this Repository method
in the whole Rails application.
"""
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
ensure_gitlab_branches_state_file(repo)
......@@ -227,6 +231,7 @@
def FindLocalBranches(self,
request: FindLocalBranchesRequest,
context) -> FindLocalBranchesResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
for chunk in chunked(iter_gitlab_branches(repo)):
yield FindLocalBranchesResponse(
......@@ -237,6 +242,7 @@
def FindAllBranches(self,
request: FindAllBranchesRequest,
context) -> FindAllBranchesResponse:
logger.debug("Processing %r", message.Logging(request))
Branch = FindAllBranchesResponse.Branch
repo = self.load_repo(request.repository, context)
for chunk in chunked(iter_gitlab_branches(repo)):
......@@ -247,6 +253,7 @@
def FindAllTags(self,
request: FindAllTagsRequest,
context) -> FindAllTagsResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
for chunk in chunked(
item for item in pycompat.iteritems(repo.tags())
......@@ -257,6 +264,7 @@
def FindTag(self,
request: FindTagRequest,
context) -> FindTagResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
name = request.tag_name
if repo.tagtype(name) in EXCLUDED_TAG_TYPES:
......@@ -271,8 +279,9 @@
request: FindAllRemoteBranchesRequest,
context) -> FindAllRemoteBranchesResponse:
"""There is no concept of "remote branch" in Mercurial."""
logger.debug("Processing %r", message.Logging(request))
return iter(())
def RefExists(self,
request: RefExistsRequest,
context) -> RefExistsResponse:
......@@ -274,8 +283,9 @@
return iter(())
def RefExists(self,
request: RefExistsRequest,
context) -> RefExistsResponse:
logger.debug("Processing %r", message.Logging(request))
ref = request.ref
if not ref.startswith(b'refs/'):
# TODO SPEC commment in ref.proto says `ref` must start with
......@@ -312,6 +322,7 @@
def FindBranch(self,
request: FindBranchRequest,
context) -> FindBranchResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
name = request.name
if name.startswith(b'refs/'):
......@@ -331,6 +342,7 @@
def DeleteRefs(self,
request: DeleteRefsRequest,
context) -> DeleteRefsResponse:
logger.debug("Processing %r", message.Logging(request))
except_prefix = request.except_with_prefix
refs = request.refs
if refs and except_prefix:
......@@ -370,6 +382,7 @@
self,
request: ListBranchNamesContainingCommitRequest,
context) -> ListBranchNamesContainingCommitResponse:
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
gl_branches_by_heads = {}
......@@ -399,6 +412,7 @@
self,
request: ListTagNamesContainingCommitRequest,
context) -> ListTagNamesContainingCommitResponse:
logger.debug("Processing %r", message.Logging(request))
# TODO support ordering, see similar method for branches
repo = self.load_repo(request.repository, context)
revs = repo.revs("%s:: and tag()", request.commit_id)
......@@ -418,6 +432,7 @@
For now, we'll consider that the id of a tag is the nod id of the
changeset that gives it its current value.
"""
logger.debug("Processing %r", message.Logging(request))
repo = self.load_repo(request.repository, context)
# TODO check that the given id is indeed for a tag, i.e. a
# changeset that affects .hgtags?
......@@ -480,10 +495,8 @@
"""Not relevant for Mercurial, does nothing.
"""
# repr(Repository) contains newlines
logger.warning("Ignored irrelevant call to PackRefs method "
"for Mercurial repository %r on storage %r",
request.repository.relative_path,
request.repository.storage_name)
logger.warning("Ignored irrelevant PackRefs request %r",
message.Logging(request))
return PackRefsResponse()
......
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