Skip to content
Snippets Groups Projects
Commit 5473e588 authored by Patrick Steinhardt's avatar Patrick Steinhardt
Browse files

Merge branch 'smh-fix-reconciling-to-unassigned' into 'master'

Check the correct record in reconciler for assignments

See merge request !3147
parents f526e631 7e8d75c4
No related branches found
No related tags found
1 merge request!3147Check the correct record in reconciler for assignments
Pipeline #257004131 passed
......@@ -162,15 +162,14 @@ WITH healthy_storages AS (
FROM repositories
JOIN healthy_storages USING (virtual_storage)
LEFT JOIN storage_repositories USING (virtual_storage, relative_path, storage)
WHERE COALESCE(storage_repositories.generation != repositories.generation, true)
AND (
-- If assignments exist for the repository, only the assigned storages are targeted for replication.
-- If no assignments exist, every healthy node is targeted for replication.
SELECT COUNT(storage) = 0 OR COUNT(storage) FILTER (WHERE storage = storage_repositories.storage) = 1
FROM repository_assignments
WHERE virtual_storage = storage_repositories.virtual_storage
AND relative_path = storage_repositories.relative_path
WHERE virtual_storage = repositories.virtual_storage
AND relative_path = repositories.relative_path
)
ORDER BY virtual_storage, relative_path
) AS unhealthy_repositories
......
......@@ -99,7 +99,6 @@ func TestReconciler(t *testing.T) {
for _, tc := range []struct {
desc string
assignmentsEnabled bool
healthyStorages storages
repositories repositories
existingJobs existingJobs
......@@ -351,9 +350,8 @@ func TestReconciler(t *testing.T) {
}},
},
{
desc: "unassigned node allowed to target an assigned node",
assignmentsEnabled: true,
healthyStorages: configuredStorages,
desc: "unassigned node allowed to target an assigned node",
healthyStorages: configuredStorages,
repositories: repositories{
"virtual-storage-1": {
"relative-path-1": {
......@@ -388,9 +386,8 @@ func TestReconciler(t *testing.T) {
},
},
{
desc: "assigned node allowed to target an assigned node",
assignmentsEnabled: true,
healthyStorages: configuredStorages,
desc: "assigned node allowed to target an assigned node",
healthyStorages: configuredStorages,
repositories: repositories{
"virtual-storage-1": {
"relative-path-1": {
......@@ -410,6 +407,17 @@ func TestReconciler(t *testing.T) {
},
},
},
{
desc: "the only assigned node being up to date produces no jobs",
healthyStorages: configuredStorages,
repositories: repositories{
"virtual-storage-1": {
"relative-path-1": {
"storage-1": {generation: 0, assigned: true},
},
},
},
},
} {
t.Run(tc.desc, func(t *testing.T) {
ctx, cancel := testhelper.Context()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment