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
31e6e995
Commit
31e6e995
authored
Jul 08, 2021
by
Dmitry Gruzd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Advanced Search: Fix inaccessible ES server error
Changelog: fixed EE: true
parent
7db9f4c6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
ee/app/models/elastic/migration_record.rb
ee/app/models/elastic/migration_record.rb
+7
-2
ee/spec/models/elastic/migration_record_spec.rb
ee/spec/models/elastic/migration_record_spec.rb
+21
-0
No files found.
ee/app/models/elastic/migration_record.rb
View file @
31e6e995
...
@@ -37,7 +37,8 @@ module Elastic
...
@@ -37,7 +37,8 @@ module Elastic
def
load_from_index
def
load_from_index
client
.
get
(
index:
index_name
,
id:
version
)
client
.
get
(
index:
index_name
,
id:
version
)
rescue
Elasticsearch
::
Transport
::
Transport
::
Errors
::
NotFound
rescue
StandardError
=>
e
logger
.
error
(
"[Elastic::MigrationRecord]:
#{
e
.
class
}
:
#{
e
.
message
}
"
)
nil
nil
end
end
...
@@ -64,7 +65,7 @@ module Elastic
...
@@ -64,7 +65,7 @@ module Elastic
.
search
(
index:
helper
.
migrations_index_name
,
body:
{
query:
{
term:
{
completed:
completed
}
},
size:
ELASTICSEARCH_SIZE
})
.
search
(
index:
helper
.
migrations_index_name
,
body:
{
query:
{
term:
{
completed:
completed
}
},
size:
ELASTICSEARCH_SIZE
})
.
dig
(
'hits'
,
'hits'
)
.
dig
(
'hits'
,
'hits'
)
.
map
{
|
v
|
v
[
'_id'
].
to_i
}
.
map
{
|
v
|
v
[
'_id'
].
to_i
}
rescue
Elasticsearch
::
Transport
::
Transport
::
Errors
::
NotFound
rescue
StandardError
[]
[]
end
end
...
@@ -103,5 +104,9 @@ module Elastic
...
@@ -103,5 +104,9 @@ module Elastic
def
helper
def
helper
Gitlab
::
Elastic
::
Helper
.
default
Gitlab
::
Elastic
::
Helper
.
default
end
end
def
logger
@logger
||=
::
Gitlab
::
Elasticsearch
::
Logger
.
build
end
end
end
end
end
ee/spec/models/elastic/migration_record_spec.rb
View file @
31e6e995
...
@@ -41,6 +41,20 @@ RSpec.describe Elastic::MigrationRecord, :elastic do
...
@@ -41,6 +41,20 @@ RSpec.describe Elastic::MigrationRecord, :elastic do
end
end
end
end
describe
'#load_from_index'
do
it
'does not raise an exeption when connection refused'
do
allow
(
Gitlab
::
Elastic
::
Helper
.
default
).
to
receive
(
:get
).
and_raise
(
Faraday
::
ConnectionFailed
)
expect
(
record
.
load_from_index
).
to
be_nil
end
it
'does not raise an exeption when record does not exist'
do
allow
(
Gitlab
::
Elastic
::
Helper
.
default
).
to
receive
(
:get
).
and_raise
(
Elasticsearch
::
Transport
::
Transport
::
Errors
::
NotFound
)
expect
(
record
.
load_from_index
).
to
be_nil
end
end
describe
'#halt!'
do
describe
'#halt!'
do
it
'sets state for halted and halted_indexing_unpaused'
do
it
'sets state for halted and halted_indexing_unpaused'
do
record
.
halt!
record
.
halt!
...
@@ -87,6 +101,13 @@ RSpec.describe Elastic::MigrationRecord, :elastic do
...
@@ -87,6 +101,13 @@ RSpec.describe Elastic::MigrationRecord, :elastic do
expect
(
described_class
.
load_versions
(
completed:
true
)).
to
eq
([])
expect
(
described_class
.
load_versions
(
completed:
true
)).
to
eq
([])
expect
(
described_class
.
load_versions
(
completed:
false
)).
to
eq
([])
expect
(
described_class
.
load_versions
(
completed:
false
)).
to
eq
([])
end
end
it
'returns empty array when exception is raised'
do
allow
(
Gitlab
::
Elastic
::
Helper
.
default
.
client
).
to
receive
(
:search
).
and_raise
(
Faraday
::
ConnectionFailed
)
expect
(
described_class
.
load_versions
(
completed:
true
)).
to
eq
([])
expect
(
described_class
.
load_versions
(
completed:
false
)).
to
eq
([])
end
end
end
describe
'#running?'
do
describe
'#running?'
do
...
...
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