Skip to content
Snippets Groups Projects
  1. Jun 14, 2023
    • Georges Racinet's avatar
      RHGitaly: reading GitLab ref files · bcab7028
      Georges Racinet authored
      This follows the file format and conventions defined in the server side
      `heptapod` Python package.
      
      Since everything is async, we actually provide Streams of TypedRef objects,
      and the `map_lookup_typed_ref` for the numerous use cases when one is looking
      for a specific ref.
      
      The file format is very primitive, so all we can do at this point is to
      perform a full scan, but it has room (version preamble) for more advanced
      formats in the future (e.g, append-only persistent hash map or similar).
      
      A preliminary version of this was using Tokio's `LineStream`, but this
      has several drawbacks:
      
      - it is unicode-centric, yielding `String`s
      - we had to implement our own `Stream`, keeping the `LineStream` as
        a field. Hence because `poll_next()` takes `&mut Pin<Self>` we had
        to write a pinning accessor, which is unsafe (see the doc for `std::pin`
        for more details).
      bcab7028
    • Georges Racinet's avatar
      RHGitaly: mapping file not found errors to `None` · 29fc9a2b
      Georges Racinet authored
      When a file contains a list of values, it is a common pattern that
      the absence of the file is equivalent to the list being empty.
      This `io_error_not_found_as_none` will help keeping duplication low
      (even if fairly trivial).
      29fc9a2b
  2. Jun 27, 2023
  3. Jun 07, 2023
  4. Jun 06, 2023
    • Georges Racinet's avatar
      FindCommit comparison tests: ensure only GitLab state files are used · 3c6b018d
      Georges Racinet authored
      Previously, the test was passing because the Python reference implementation
      of HGitaly relies on `scmutil.revsingle` for revisions not found in GitLab
      state files, including tags given in simple form (e.g. `v1.2.3`).
      
      But RHGitaly will rely on the GitLab state files only, hence we need to
      ensure that the tags state file contains the one we introduce, which is
      shadowing in the short SHA case
      
      The added GitLab sync has the effect of removing directly set tags that have
      no Mercurial counterpart from the GitLab state file, that's why it has to occur
      before `write_ref()` in this test of collision/shadowing were Mercurial and Git
      tags must have different names.
      3c6b018d
    • Georges Racinet's avatar
      revision: precedence rules in case of collisions · bbca598e
      Georges Racinet authored
      As illustrated with the new assertions in `test_compare_find_commit`,
      it turns out that in Gitaly, tags have precedence over branches
      (unsurprisingly) and over shortened commit ids, but not on full commit
      ids.
      bbca598e
  5. Jun 04, 2023
  6. May 26, 2023
  7. May 16, 2023
  8. May 15, 2023
    • Georges Racinet's avatar
      revision: support fully qualified tag refs · 88981e79
      Georges Racinet authored
      There was even an old TODO about that
      88981e79
    • Georges Racinet's avatar
      FindCommit: initial Gitaly Comparison test · 364d32a1
      Georges Racinet authored
      This method of the `CommitService` had no Gitaly Comparison test,
      because it was implemented before these tests were even considered.
      
      Such a test will be the main testing of the upcoming RHGitaly
      implementation.
      
      It turns out that we found a missing case: tag in the fully qualified
      ref notation (chances are that clients woud rather use `RefService.FindTag`
      but one never knows.
      364d32a1
    • Georges Racinet's avatar
      Gitaly Comparison tests: avoid side effect in normalization · 82cdf442
      Georges Racinet authored
      In some cases where a message attribute is missing, our normalization
      would have replaced it with a default (empty) value, leading to
      false positives.
      
      This is for instance the case of an empty `FindCommitResponse` (no
      commit attribute) that it would convert to a `FindCommitResponse` with
      an empy `commit` attribute (part of actual tests in the process of
      being written).
      82cdf442
    • Georges Racinet's avatar
      Gitaly Comparison tests: refactor message_to_git · 01c92a1f
      Georges Racinet authored
      A separate method for each "attribute path" gives us a bit more
      clarity (early return if `recurse` rather than a boolean available
      from outside the inner loop), and more room for improvement.
      01c92a1f
  9. May 14, 2023
    • Georges Racinet's avatar
      Gitaly Comparison test harness: always using the bundled Git · 8135fc70
      Georges Racinet authored
      Recent Gitaly versions come with two versions of Git (probably to
      test them in advance), and hence the path that we were trying is
      no longer valid.
      
      It is now mandatory of to the development setup (HDK) and to the CI base
      image to provide Gitaly with the bundled Git.
      The concept of "bundled Git" seems to go beyond vendoring, the
      compilation flag `WITH_BUNDLED_GIT=YesPlease` has the effect of
      putting self-sufficient Git executables in Gitaly bin directory, which
      the main executable knows how to find and select, provided that the
      `bin_dir` configuration item is correct (fixed in a preparation changeset).
      
      Using this bundled Git removes lots of confusion and timebombs
      such as the tests defaulting to a system-wide Git which suddenly can
      become outdated.
      8135fc70
    • Georges Racinet's avatar
      Gitaly Comparison test harness: cleanup refactoring · 5b697cb2
      Georges Racinet authored
      Since we only test one candidate `gitaly` executable, we don't
      need the loop.
      5b697cb2
    • Georges Racinet's avatar
      Gitaly Comparison test harness: fixing Gitaly bin_dir · 4250ce07
      Georges Racinet authored
      In case the `gitaly` executable is to be found in a subdirectory
      of `GITALY_INSTALL_DIR`, then that same subdirectory has to be
      provided as the `bin_dir` configuration item, so that Gitaly can
      find all its non-ruby bundled executables, notably the bundled Git.
      
      It was working until now because Gitaly falls back to a system-wide
      Git if the specified one is not found, whose version is acceptable
      in CI because the `heptapod-gitaly` base image is itself based on the
      `heptapod-base` image, which provides the Git version generally
      accepted by the target GitLab version.
      
      Since there is no doubt as to where the `gitaly` executable is supposed
      to sit, we're only testing one possibility (minimal change to keep the diff
      understable, to be refactored).
      4250ce07
  10. May 03, 2023
  11. May 01, 2023
  12. Apr 30, 2023
    • Georges Racinet's avatar
      workdir: customized roster lock for breaking logic as in reservation. · 5976d391
      Georges Racinet authored
      Again, we don't want the application to be locked for the wrong reason,
      e.g. lock held by a former process, but hostname has changed in the mean time.
      
      We also take the opportunity to use shorter timeout and delay
      betweeni locking attempts.
      
      The customatbility of the breaking logic and of the timeouts could be submitted
      UPSTREAM as options to Mercurial core, although it would be of limited interest to
      Heptapod right now: we cannot readily apply the same logic to other Mercurial locks,
      because HGitaly does not have exclusivity on them.
      Querying the system service manager (systemd or runit) about the Heptapod services
      would be a promising idea to do better, but we'd still have the issue that pushes
      over SSH would create standalone processes.
      5976d391
  13. Apr 26, 2023
    • Georges Racinet's avatar
      workdir: auto-release if held by an invalid process id · fb44e1f5
      Georges Racinet authored
      The rationale is that if a working directory is being held by a process (existing
      or not) that is not considered part of the HGitaly system service, it means that
      the process was killed before it could release the working directory and the pid
      is either not in use or has been reused for an unrelated process. The underlying
      assumption is that only HGitaly is supposed to make such working directories.
      
      This could be further expanded to the roster lock.
      
      Had to put `is_current_service_process` in a separate top level module
      instead of, e.g., `server.mono` to avoid import loop:
        server.mono imports services import workdir import server.mono
      
      We need to use pytest-cov's `cleanup_on_signal` again. This time,
      it's easier as the subprocess startup function is defined by the test itself.
      fb44e1f5
  14. Apr 25, 2023
    • Georges Racinet's avatar
      server.mono: covering the startup function · 57761166
      Georges Racinet authored
      The trick is that we fall precisely in the case where pytest-cov
      needs a hand: termination by signal (SIGTERM), hence we need the
      `cleanup_on_signal` method.
      
      Unfortunately, this does not work with pytest-7.3.1 and pytest-cov-4.0.0
      as the previously lax `test-requirements.txt` would install (detected
      on the `heptapod-gitaly` base image, which does not preinstall these),
      so we fix versions as they are in py-heptapod (hence also as they already
      were in HDK settups, since `py-heptapod` is installed first).
      
      Then, we need the server to actually be running to be sure that
      the handling has been done before we terminate.
      
      Still not covering the case of `SIGINT` while doing some
      Mercurial processing. We'd probably need to launch a long enough
      gRPC method for that.
      57761166
    • Georges Racinet's avatar
      Comparison tests: moved server full startup wait function to hgitaly pkg · 86e2b479
      Georges Racinet authored
      This makes it importable from the whole code base, and is already
      somewhat cleaner in the `tests_with_gitaly.rhgitaly` module.
      86e2b479
  15. Apr 24, 2023
    • Georges Racinet's avatar
      servicer: expose context manager for working directories on self · 15c56172
      Georges Racinet authored
      This wraps things together by passing down the proper root of working
      directories for the given repo (as prescribed in the Gitaly `Repository`
      message.
      
      The test is a simplified version of a service method creating changesets.
      15c56172
    • Georges Racinet's avatar
      servicer: split out relative path normalization · dc2defec
      Georges Racinet authored
      It has already been the case in Heptapod that relative path in
      Gitaly Repository messages were to be passed as if the repository
      was a Git repository (hence ending in `.git`) and then to be
      normalized as `.hg` for Mercurial operation. But this is due
      to the legacy hg-git based integration, and could not be necessary
      in some future.
      
      Meanwhile, we'll need to reuse the logic for working directories.
      dc2defec
    • Georges Racinet's avatar
      working directories: garbage collection · 081e8130
      Georges Racinet authored
      This is to be called as part of ordinary housekeeping.
      
      Another subject to be tackled on would be release of
      working directories held by defunct processes, which would
      introduce a more satisfactory breaking logic, also applicable
      to the roster lock.
      081e8130
  16. Apr 09, 2023
    • Georges Racinet's avatar
      working directories: inner pool handling · b3e7a172
      Georges Racinet authored
      This creates the pool, recorded as a "roster" file
      in the main repository.
      
      To obtain an exclusive working directory, callers should
      use the `working_directory` context manager only.
      
      The roster file is protected by a lock, with input/output
      occurring only at acquire and release times of working
      directories, allowing to acquire working directories freely
      when one is already held. The lock is for now provided by
      Mercurial standard utilities, but we will probably implement
      a more suitable one later on.
      
      A cleanup system for old working directories shall be implemented
      in a following changeset. It will be based on the recorded timestamp.
      b3e7a172
  17. Apr 28, 2023
  18. Apr 27, 2023
  19. Apr 26, 2023
    • Georges Racinet's avatar
      branch: avoid fallback analysis on empty repos · 141dab17
      Georges Racinet authored
      We've been worried to see so many "defaulting to slow direct
      analysis" in the logs (especially in developer setups), as we
      are on the verge to rely on the GitLab state files only in some
      cases (RHGitaly).
      
      It turns out that all such logs emitted by a local functional tests
      run were actually about empty repos
      (`heptapod-tests-run --heptapod-remote --heptapod-hg-native=full`).
      It will be interesting to check foss.heptapod.net logs. In theory, we
      should not see any such warning.
      
      The early returns are of course much simpler, not sure if that
      is a performance boost in general, though, since the condition will be
      checked for all calls and most of them are not on empty repositories.
      141dab17
    • Georges Racinet's avatar
      RHGitaly: avoid logging all metadata · 32b0304d
      Georges Racinet authored
      Logging all invocation metadata is verbose and contains secrets
      (authentication header). Of these, only the `correlation_id` is
      interesting to us at the moment.
      
      To achieve this, we split the service method with an inner method
      taking the inner request and the correlation id. Only the inner
      method is now instrumented.
      
      This is heavy for the implementation.
      We tried not to split, using the `fields` modifier like this:
      
      ```
          #[instrument(skip(self, request), fields(request = request.get_ref()))]
      ```
      
      and it ended up giving "`RepositoryRequest` does not implement tracing::Value`"
      
      The splitting will be good enough for now.
      32b0304d
    • Georges Racinet's avatar
      Gitaly Comparision test_tree_entry_requests: giving up on comparing chunk size · dee21e96
      Georges Racinet authored
      Basically, Gitaly chunk lengths are partly unpredictable. We tried to approximate
      them, but we can't really depend on them in assertions.
      
      The irritating thing is that this test failed often in CI (clear majority of runs,
      yet not all of them) and passed almost always on my development setup. The CI
      flakiness is now too much of a pain to keep it.
      
      Passing the `compare_first_chunks=False` does not change the fact that the
      entire content is compared and that metadata (aka small fields or unchunked fiels)
      are compared for all chunks (added a clarification in docstring about that).
      dee21e96
  20. Apr 25, 2023
  21. Apr 24, 2023
Loading