diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-21 21:08:43 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-21 21:08:43 +0000 |
commit | 6216eabd1c94ac7e560b4f43b164bff73e17b0da (patch) | |
tree | e4c4747a2474f4575732f11d023fc411dec2dba2 /.gitlab/issue_templates | |
parent | 2c87a975e36acc152da28665d39ca720f479fe53 (diff) | |
download | gitlab-ce-6216eabd1c94ac7e560b4f43b164bff73e17b0da.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to '.gitlab/issue_templates')
-rw-r--r-- | .gitlab/issue_templates/Geo Replicate a new Git repository type.md | 37 | ||||
-rw-r--r-- | .gitlab/issue_templates/Geo Replicate a new blob type.md | 38 |
2 files changed, 73 insertions, 2 deletions
diff --git a/.gitlab/issue_templates/Geo Replicate a new Git repository type.md b/.gitlab/issue_templates/Geo Replicate a new Git repository type.md index e858f80ffaa..b39356e74bd 100644 --- a/.gitlab/issue_templates/Geo Replicate a new Git repository type.md +++ b/.gitlab/issue_templates/Geo Replicate a new Git repository type.md @@ -104,7 +104,7 @@ Geo secondary sites have a [Geo tracking database](https://gitlab.com/gitlab-org - [ ] Run Geo tracking database migrations: ```shell - bin/rake geo:db:migrate + bin/rake db:migrate:geo ``` - [ ] Be sure to commit the relevant changes in `ee/db/geo/structure.sql` @@ -673,6 +673,41 @@ The GraphQL API is used by `Admin > Geo > Replication Details` views, and is dir Individual Cool Widget replication and verification data should now be available via the GraphQL API. +#### Step 4. Handle batch destroy + +If batch destroy logic is implemented for a replicable, then that logic must be "replicated" by Geo secondaries. The easiest way to do this is use `Geo::BatchEventCreateWorker` to bulk insert a delete event for each replicable. + +For example, if `FastDestroyAll` is used, then you may be able to [use `begin_fast_destroy` and `finalize_fast_destroy` hooks, like we did for uploads](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69763). + +Or if a special service is used to batch delete records and their associated data, then you probably need to [hook into that service, like we did for job artifacts](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79530). + +As illustrated by the above two examples, batch destroy logic cannot be handled automatically by Geo secondaries without restricting the way other teams perform batch destroys. It is up to you to produce `Geo::BatchEventCreateWorker` attributes before the records are deleted, and then enqueue `Geo::BatchEventCreateWorker` after the records are deleted. + +- [ ] Ensure that any batch destroy of this replicable is replicated to secondary sites +- [ ] Regardless of implementation details, please verify in specs that when the parent object is removed, the new `Geo::Event` records are created: + +```ruby + describe '#destroy' do + subject { create(:cool_widget) } + + context 'when running in a Geo primary node' do + let_it_be(:primary) { create(:geo_node, :primary) } + let_it_be(:secondary) { create(:geo_node) } + + it 'logs an event to the Geo event log when bulk removal is used', :sidekiq_inline do + stub_current_geo_node(primary) + + expect { subject.project.destroy! }.to change(Geo::Event.where(replicable_name: :cool_widget, event_name: :deleted), :count).by(1) + + payload = Geo::Event.where(replicable_name: :cool_widget, event_name: :deleted).last.payload + + expect(payload['model_record_id']).to eq(subject.id) + expect(payload['blob_path']).to eq(subject.relative_path) + expect(payload['uploader_class']).to eq('CoolWidgetUploader') + end + end + end +``` ### Release Geo support of Cool Widgets - [ ] In the rollout issue you created when creating the feature flag, modify the Roll Out Steps: diff --git a/.gitlab/issue_templates/Geo Replicate a new blob type.md b/.gitlab/issue_templates/Geo Replicate a new blob type.md index 0cbfd79c958..d005e0cdf43 100644 --- a/.gitlab/issue_templates/Geo Replicate a new blob type.md +++ b/.gitlab/issue_templates/Geo Replicate a new blob type.md @@ -104,7 +104,7 @@ Geo secondary sites have a [Geo tracking database](https://gitlab.com/gitlab-org - [ ] Run Geo tracking database migrations: ```shell - bin/rake geo:db:migrate + bin/rake db:migrate:geo ``` - [ ] Be sure to commit the relevant changes in `ee/db/geo/structure.sql` @@ -637,6 +637,42 @@ The GraphQL API is used by `Admin > Geo > Replication Details` views, and is dir Individual Cool Widget replication and verification data should now be available via the GraphQL API. +#### Step 4. Handle batch destroy + +If batch destroy logic is implemented for a replicable, then that logic must be "replicated" by Geo secondaries. The easiest way to do this is use `Geo::BatchEventCreateWorker` to bulk insert a delete event for each replicable. + +For example, if `FastDestroyAll` is used, then you may be able to [use `begin_fast_destroy` and `finalize_fast_destroy` hooks, like we did for uploads](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69763). + +Or if a special service is used to batch delete records and their associated data, then you probably need to [hook into that service, like we did for job artifacts](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79530). + +As illustrated by the above two examples, batch destroy logic cannot be handled automatically by Geo secondaries without restricting the way other teams perform batch destroys. It is up to you to produce `Geo::BatchEventCreateWorker` attributes before the records are deleted, and then enqueue `Geo::BatchEventCreateWorker` after the records are deleted. + +- [ ] Ensure that any batch destroy of this replicable is replicated to secondary sites +- [ ] Regardless of implementation details, please verify in specs that when the parent object is removed, the new `Geo::Event` records are created: + +```ruby + describe '#destroy' do + subject { create(:cool_widget) } + + context 'when running in a Geo primary node' do + let_it_be(:primary) { create(:geo_node, :primary) } + let_it_be(:secondary) { create(:geo_node) } + + it 'logs an event to the Geo event log when bulk removal is used', :sidekiq_inline do + stub_current_geo_node(primary) + + expect { subject.project.destroy! }.to change(Geo::Event.where(replicable_name: :cool_widget, event_name: :deleted), :count).by(1) + + payload = Geo::Event.where(replicable_name: :cool_widget, event_name: :deleted).last.payload + + expect(payload['model_record_id']).to eq(subject.id) + expect(payload['blob_path']).to eq(subject.relative_path) + expect(payload['uploader_class']).to eq('CoolWidgetUploader') + end + end + end +``` + ### Release Geo support of Cool Widgets - [ ] In the rollout issue you created when creating the feature flag, modify the Roll Out Steps: |