Fixing project namespace traversal_ids syncing
What does this MR do and why?
Addressing this issue from customer: #387844 (closed)
This will fix the syncing of the traversal_ids
of the ProjectNamespace
s when the feature flag use_traversal_ids_for_ancestors
is disabled.
The original problem has been explained in details here: #388820 (closed)
How to set up and validate locally
You can test this using the rails console on both master
and this branch, and see the difference.
Steps to validate locally
Create the test data
To make the setup look like self-managed
Feature.disable(:use_traversal_ids_for_ancestors)
Create group1, group2 and project_namespace
g1 = FactoryBot.create(:group, name: "test" + (0...6).map { (65 + rand(26)).chr }.join); nil
g2 = FactoryBot.create(:group, name: "test" + (0...6).map { (65 + rand(26)).chr }.join,parent: g1); nil
p = FactoryBot.create(:project_namespace, name: "test" + (0...8).map { (65 + rand(26)).chr }.join, parent: g2); nil
If creating the project_namespace
fails due to a conflict on the path/name, create it again.
reload the traversal_ids on the two groups
[g1, g2, p].each(&:reload); nil
Sync the namespaces to the CI side
Namespaces::SyncEvent.all.each { |e| Ci::NamespaceMirror.sync!(e) }; nil
Namespaces::SyncEvent.delete_all
Print the traversal_ids of the source namespaces
[g1, g2, p].each { |n| puts n.traversal_ids.inspect }; nil
Print the traversal_ids of the CI mirrored objects
This will print the wrong traversal_ids on master
, but the correct traversal_ids on this branch
[g1, g2, p].each { |n| puts n.ci_namespace_mirror.traversal_ids.inspect }; nil
Clean Up
[g1, g2, p].each(&:delete)
Namespaces::SyncEvent.delete_all
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #387844 (closed)
Edited by Omar Qunsul