-
- Downloads
Fix bug where destroying a namespace would not always destroy projects
There is a race condition in DestroyGroupService now that projects are deleted asynchronously: 1. User attempts to delete group 2. DestroyGroupService iterates through all projects and schedules a Sidekiq job to delete each Project 3. DestroyGroupService destroys the Group, leaving all its projects without a namespace 4. Projects::DestroyService runs later but the can?(current_user, :remove_project) is `false` because the user no longer has permission to destroy projects with no namespace. 5. This leaves the project in pending_delete state with no namespace/group. Projects without a namespace or group also adds another problem: it's not possible to destroy the container registry tags, since container_registry_path_with_namespace is the wrong value. The fix is to destroy the group asynchronously and to run execute directly on Projects::DestroyService. Closes #17893
Showing
- CHANGELOG 1 addition, 0 deletionsCHANGELOG
- app/controllers/admin/groups_controller.rb 2 additions, 2 deletionsapp/controllers/admin/groups_controller.rb
- app/controllers/groups_controller.rb 2 additions, 2 deletionsapp/controllers/groups_controller.rb
- app/models/namespace.rb 2 additions, 0 deletionsapp/models/namespace.rb
- app/services/delete_user_service.rb 6 additions, 1 deletionapp/services/delete_user_service.rb
- app/services/destroy_group_service.rb 13 additions, 3 deletionsapp/services/destroy_group_service.rb
- app/workers/group_destroy_worker.rb 17 additions, 0 deletionsapp/workers/group_destroy_worker.rb
- db/migrate/20140407135544_fix_namespaces.rb 8 additions, 2 deletionsdb/migrate/20140407135544_fix_namespaces.rb
- db/migrate/20160805041956_add_deleted_at_to_namespaces.rb 12 additions, 0 deletionsdb/migrate/20160805041956_add_deleted_at_to_namespaces.rb
- db/schema.rb 2 additions, 0 deletionsdb/schema.rb
- spec/controllers/admin/groups_controller_spec.rb 24 additions, 0 deletionsspec/controllers/admin/groups_controller_spec.rb
- spec/controllers/groups_controller_spec.rb 29 additions, 0 deletionsspec/controllers/groups_controller_spec.rb
- spec/requests/api/users_spec.rb 2 additions, 0 deletionsspec/requests/api/users_spec.rb
- spec/services/delete_user_service_spec.rb 4 additions, 2 deletionsspec/services/delete_user_service_spec.rb
- spec/services/destroy_group_service_spec.rb 36 additions, 22 deletionsspec/services/destroy_group_service_spec.rb
- spec/workers/group_destroy_worker_spec.rb 19 additions, 0 deletionsspec/workers/group_destroy_worker_spec.rb
Loading
Please register or sign in to comment