diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2021-10-11 14:35:20 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2021-10-15 11:59:18 +0300 |
commit | 50b968e886105096edf17a9a003658f27555180a (patch) | |
tree | 7ad3c665de3e4ee426ddfd56f4877aad27ebccf5 /cmd | |
parent | a27584d74cf557aca5b659066560f02bfe4d5f32 (diff) |
Get host assignment by repository ID
Praefect's routing should use repository ID consistently in all of the
queries in order to avoid races where the external key of the repository
changes between the various queries. This commit updates GetHostAssignments
to get assignments by the repository's ID rather than its virtual storage
and relative path.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/praefect/subcmd_track_repository_test.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd/praefect/subcmd_track_repository_test.go b/cmd/praefect/subcmd_track_repository_test.go index 4f03576ed..41af66343 100644 --- a/cmd/praefect/subcmd_track_repository_test.go +++ b/cmd/praefect/subcmd_track_repository_test.go @@ -182,7 +182,10 @@ func TestAddRepository_Exec(t *testing.T) { require.NoError(t, addRepoCmd.Exec(flag.NewFlagSet("", flag.PanicOnError), addCmdConf)) as := datastore.NewAssignmentStore(db, conf.StorageNames()) - assignments, err := as.GetHostAssignments(ctx, virtualStorageName, relativePath) + repositoryID, err := repoDS.GetRepositoryID(ctx, virtualStorageName, relativePath) + require.NoError(t, err) + + assignments, err := as.GetHostAssignments(ctx, virtualStorageName, repositoryID) require.NoError(t, err) require.Len(t, assignments, 2) assert.Contains(t, assignments, g1Cfg.Storages[0].Name) |