1. 10 Nov, 2021 3 commits
    • Patrick Steinhardt's avatar
      repository: Do not fail if repository exists already · ddf054fe
      Patrick Steinhardt authored
      The `#create_if_not_exists` function is supposed to create a repository
      if it doesn't exist yet. It may happen though that the existence-cache
      may pretend a repo doesn't exist yet even though it does, and in that
      case we'd call the CreateRepository RPC. This worked alright until now
      given that this RPC call is idempotent and simply reinitializes the repo
      in case it exists already. But Gitaly is going to change semantics of
      the RPC such that it raises an error if the repo exists already, where
      it then won't touch the preexisting repo at all.
      
      Prepare for this change by introducing a new `RepositoryExists` error
      which gets raised when `#create_repository` returns an AlreadyExists
      error. This error is rescued from in `#create_if_not_exists` such that
      semantics of this RPC call remain the same.
      ddf054fe
    • Patrick Steinhardt's avatar
      spec: Do not stub temporary repo in sync service shared examples · a40a136e
      Patrick Steinhardt authored
      When synchronizing repositories, then depending on a retry counter we
      may either fetch into the real repository, or recreate the repo by first
      creating a temporary staging repository, populating that repository and
      then moving it into place. Our tests stub out this logic though such
      that we always end up fetching into the real repository: this both keeps
      us from exercising whether we fetch into the expected repo, and this
      logic will break when Gitaly changes semantics of the CreateRepository
      RPC to raise an error if the repository exists already.
      
      Fix this issue by not stubbing out the temporary repository. Instead, we
      now assert that function calls end up using the correct repository.
      a40a136e
    • Patrick Steinhardt's avatar
      spec: Do not recreate existing snippet repositories · 67082753
      Patrick Steinhardt authored
      In order to set up snippet repositories in some of our tests, we first
      copy over a template repository into the target location and then call
      Gitaly's `CreateRepository()`. While this call wouldn't do anything if
      used with Gitaly only given that the RPC is idempotent, it would create
      a database record when Gitaly is proxied by Praefect.
      
      Gitaly is about to drop idempotentcy of `CreateRepository()`, where it
      will instead raise an error. Prepare for this by reversing calls such
      that we first create the repository in Gitaly, and then copy over
      contents of our seed repository.
      67082753
  2. 08 Nov, 2021 37 commits