Page MenuHomePhabricator

In the repository URI index, store Phabricator's own URIs as tokens
ClosedPublic

Authored by epriestley on Oct 28 2019, 9:35 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 5:02 PM
Unknown Object (File)
Wed, Nov 20, 5:02 PM
Unknown Object (File)
Wed, Nov 20, 3:35 PM
Unknown Object (File)
Thu, Nov 14, 11:52 AM
Unknown Object (File)
Sat, Nov 9, 3:58 PM
Unknown Object (File)
Sat, Nov 9, 3:57 PM
Unknown Object (File)
Sat, Nov 9, 3:57 PM
Unknown Object (File)
Wed, Nov 6, 12:21 AM
Subscribers
Restricted Owners Package

Details

Summary

Fixes T13435. If you move Phabricator or copy data from one environment to another, the repository URI index currently still references the old URI, since it writes the URI as a plain string. This may make "arc which" and similar workflows have difficulty identifying repositories.

Instead, store the "phabricator.base-uri" domain and the "diffusion.ssh-host" domain as tokens, so lookups continue to work correctly even after these values change.

Test Plan
  • Added unit tests to cover the normalization.
  • Ran migration, ran daemons, inspected repository_uriindex table, saw a mixture of sensible tokens (for local domains) and static domains (like "github.com").
  • Ran this thing:
$ echo '{"remoteURIs": ["ssh://git@local.phacility.com/diffusion/P"]}' | ./bin/conduit call --method repository.query --trace --input -
Reading input from stdin...
>>> [2] (+0) <conduit> repository.query()
>>> [3] (+3) <connect> local_repository
<<< [3] (+3) <connect> 555 us
>>> [4] (+5) <query> SELECT `r`.* FROM `repository` `r` LEFT JOIN `local_repository`.`repository_uriindex` uri ON r.phid = uri.repositoryPHID WHERE (uri.repositoryURI IN ('<base-uri>/diffusion/P')) GROUP BY `r`.phid ORDER BY `r`.`id` DESC LIMIT 101
<<< [4] (+5) <query> 596 us
<<< [2] (+6) <conduit> 6,108 us
{
  "result": [
    {
      "id": "1",
      "name": "Phabricator",
      "phid": "PHID-REPO-2psrynlauicce7d3q7g2",
      "callsign": "P",
      "monogram": "rP",
      "vcs": "git",
      "uri": "http://local.phacility.com/source/phabricator/",
      "remoteURI": "https://github.com/phacility/phabricator.git",
      "description": "asdf",
      "isActive": true,
      "isHosted": false,
      "isImporting": false,
      "encoding": "UTF-8",
      "staging": {
        "supported": true,
        "prefix": "phabricator",
        "uri": null
      }
    }
  ]
}

Note the WHERE clause in the query normalizes the URI into "<base-uri>", and the lookup succeeds.

Diff Detail

Repository
rP Phabricator
Branch
token1
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 23586
Build 32418: Run Core Tests
Build 32417: arc lint + arc unit

Event Timeline

Owners added a subscriber: Restricted Owners Package.Oct 28 2019, 9:35 PM
This revision was not accepted when it landed; it landed in state Needs Review.Oct 28 2019, 9:44 PM
This revision was automatically updated to reflect the committed changes.