Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
42eb2e7f
Commit
42eb2e7f
authored
Jun 07, 2021
by
Dmitry Gruzd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old Advanced Search migrations
Changelog: changed EE: true
parent
d6cc7c98
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
77 additions
and
41 deletions
+77
-41
doc/development/elasticsearch.md
doc/development/elasticsearch.md
+4
-11
ee/app/models/elastic/migration_record.rb
ee/app/models/elastic/migration_record.rb
+3
-1
ee/app/services/elastic/data_migration_service.rb
ee/app/services/elastic/data_migration_service.rb
+9
-0
ee/app/workers/concerns/elastic/migration_obsolete.rb
ee/app/workers/concerns/elastic/migration_obsolete.rb
+21
-0
ee/elastic/migrate/20201105181100_apply_max_analyzed_offset.rb
...astic/migrate/20201105181100_apply_max_analyzed_offset.rb
+1
-28
ee/lib/elastic/migration.rb
ee/lib/elastic/migration.rb
+4
-0
ee/spec/elastic/migrate/20210128163600_add_permissions_data_to_notes_documents_spec.rb
...128163600_add_permissions_data_to_notes_documents_spec.rb
+0
-0
ee/spec/support/helpers/elasticsearch_helpers.rb
ee/spec/support/helpers/elasticsearch_helpers.rb
+1
-1
ee/spec/workers/concerns/elastic/migration_obsolete_spec.rb
ee/spec/workers/concerns/elastic/migration_obsolete_spec.rb
+34
-0
No files found.
doc/development/elasticsearch.md
View file @
42eb2e7f
...
...
@@ -308,7 +308,8 @@ We choose to use GitLab major version upgrades as a safe time to remove
backwards compatibility for indices that have not been fully migrated. We
[
document this in our upgrade
documentation
](
../update/index.md#upgrading-to-a-new-major-version
)
. We also
choose to remove the migration code and tests so that:
choose to remove the migration code by replacing it with the halted migration
and remove tests so that:
-
We don't need to maintain any code that is called from our Advanced Search
migrations.
...
...
@@ -334,18 +335,10 @@ For every migration that was created 2 minor versions before the major version
being upgraded to, we do the following:
1.
Confirm the migration has actually completed successfully for GitLab.com.
1.
Replace the content of
`migrate`
and
`completed?`
methods as follows
:
1.
Replace the content of
the migration with
:
```
ruby
def
migrate
log_raise
"Migration has been deleted in the last major version upgrade."
\
"Migrations are supposed to be finished before upgrading major version https://docs.gitlab.com/ee/update/#upgrading-to-a-new-major-version ."
\
"To correct this issue, recreate your index from scratch: https://docs.gitlab.com/ee/integration/elasticsearch.html#last-resort-to-recreate-an-index."
end
def
completed?
false
end
include
Elastic
::
MigrationObsolete
```
1.
Delete any spec files to support this migration.
...
...
ee/app/models/elastic/migration_record.rb
View file @
42eb2e7f
...
...
@@ -4,7 +4,9 @@ module Elastic
class
MigrationRecord
attr_reader
:version
,
:name
,
:filename
delegate
:migrate
,
:skip_migration?
,
:completed?
,
:batched?
,
:throttle_delay
,
:pause_indexing?
,
:space_requirements?
,
:space_required_bytes
,
to: :migration
delegate
:migrate
,
:skip_migration?
,
:completed?
,
:batched?
,
:throttle_delay
,
:pause_indexing?
,
:space_requirements?
,
:space_required_bytes
,
:obsolete?
,
to: :migration
ELASTICSEARCH_SIZE
=
25
...
...
ee/app/services/elastic/data_migration_service.rb
View file @
42eb2e7f
...
...
@@ -29,6 +29,15 @@ module Elastic
migrations
.
find
{
|
migration
|
migration
.
name_for_key
==
name
.
to_s
.
underscore
}
end
def
find_by_name!
(
name
)
migration
=
find_by_name
(
name
)
raise
ArgumentError
,
"Couldn't find Elastic::Migration with name='
#{
name
}
'"
unless
migration
raise
ArgumentError
,
"Elastic::Migration with name='
#{
name
}
' is marked as obsolete"
if
migration
.
obsolete?
migration
end
def
drop_migration_has_finished_cache!
(
migration
)
Rails
.
cache
.
delete
cache_key
(
:migration_has_finished
,
migration
.
name_for_key
)
end
...
...
ee/app/workers/concerns/elastic/migration_obsolete.rb
0 → 100644
View file @
42eb2e7f
# frozen_string_literal: true
module
Elastic
module
MigrationObsolete
def
migrate
log
"Migration has been deleted in the last major version upgrade."
\
"Migrations are supposed to be finished before upgrading major version https://docs.gitlab.com/ee/update/#upgrading-to-a-new-major-version ."
\
"To correct this issue, recreate your index from scratch: https://docs.gitlab.com/ee/integration/elasticsearch.html#last-resort-to-recreate-an-index."
fail_migration_halt_error!
end
def
completed?
false
end
def
obsolete?
true
end
end
end
ee/elastic/migrate/20201105181100_apply_max_analyzed_offset.rb
View file @
42eb2e7f
# frozen_string_literal: true
class
ApplyMaxAnalyzedOffset
<
Elastic
::
Migration
# Important: Any update to the Elastic index mappings should be replicated in Elastic::Latest::Config
def
migrate
if
max_analyzed_offset_setting
==
current_max_analyzed_offset
log
"Skipping highlight.max_analyzed_offset migration since it is already applied"
return
end
log
"Setting highlight.max_analyzed_offset to
#{
max_analyzed_offset_setting
}
kb"
helper
.
update_settings
(
settings:
{
index:
{
'highlight.max_analyzed_offset'
:
max_analyzed_offset_setting
}
})
log
'Update of highlight.max_analyzed_offset is completed'
end
# Check if the migration has completed
# Return true if completed, otherwise return false
def
completed?
max_analyzed_offset_setting
==
current_max_analyzed_offset
end
private
def
max_analyzed_offset_setting
Gitlab
::
CurrentSettings
.
elasticsearch_indexed_file_size_limit_kb
.
kilobytes
end
def
current_max_analyzed_offset
Gitlab
::
Elastic
::
Helper
.
default
.
get_settings
.
dig
(
'highlight'
,
'max_analyzed_offset'
).
to_i
end
include
Elastic
::
MigrationObsolete
end
ee/lib/elastic/migration.rb
View file @
42eb2e7f
...
...
@@ -23,6 +23,10 @@ module Elastic
raise
NotImplementedError
,
'Please extend Elastic::Migration'
end
def
obsolete?
false
end
private
def
helper
...
...
ee/spec/elastic/migrate/20210128163600
0
_add_permissions_data_to_notes_documents_spec.rb
→
ee/spec/elastic/migrate/20210128163600_add_permissions_data_to_notes_documents_spec.rb
View file @
42eb2e7f
File moved
ee/spec/support/helpers/elasticsearch_helpers.rb
View file @
42eb2e7f
...
...
@@ -43,7 +43,7 @@ module ElasticsearchHelpers
version
=
if
name_or_version
.
is_a?
(
Numeric
)
name_or_version
else
Elastic
::
DataMigrationService
.
find_by_name
(
name_or_version
).
version
Elastic
::
DataMigrationService
.
find_by_name
!
(
name_or_version
).
version
end
Elastic
::
DataMigrationService
.
migrations
.
each
do
|
migration
|
...
...
ee/spec/workers/concerns/elastic/migration_obsolete_spec.rb
0 → 100644
View file @
42eb2e7f
# frozen_string_literal: true
require
'fast_spec_helper'
RSpec
.
describe
Elastic
::
MigrationObsolete
do
let
(
:migration_class
)
do
Class
.
new
do
include
Elastic
::
MigrationObsolete
end
end
subject
{
migration_class
.
new
}
describe
'#migrate'
do
it
'logs a message and halts the migration'
do
expect
(
subject
).
to
receive
(
:log
).
with
(
/has been deleted in the last major version upgrade/
)
expect
(
subject
).
to
receive
(
:fail_migration_halt_error!
).
and_return
(
true
)
subject
.
migrate
end
end
describe
'#completed?'
do
it
'returns false'
do
expect
(
subject
.
completed?
).
to
be
false
end
end
describe
'#obsolete?'
do
it
'returns true'
do
expect
(
subject
.
obsolete?
).
to
be
true
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment