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
101d747d
Commit
101d747d
authored
Feb 01, 2021
by
Changzheng Liu
Committed by
Douglas Barbosa Alexandre
Feb 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore connection error when changing the Elasticsearch Server URL
parent
f532e9b6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
5 deletions
+29
-5
ee/app/services/ee/application_settings/update_service.rb
ee/app/services/ee/application_settings/update_service.rb
+14
-4
ee/changelogs/unreleased/296032_ignore_es_connection_exception.yml
...logs/unreleased/296032_ignore_es_connection_exception.yml
+5
-0
ee/spec/services/application_settings/update_service_spec.rb
ee/spec/services/application_settings/update_service_spec.rb
+10
-1
No files found.
ee/app/services/ee/application_settings/update_service.rb
View file @
101d747d
...
@@ -20,7 +20,7 @@ module EE
...
@@ -20,7 +20,7 @@ module EE
elasticsearch_project_ids
=
params
.
delete
(
:elasticsearch_project_ids
)
elasticsearch_project_ids
=
params
.
delete
(
:elasticsearch_project_ids
)
if
result
=
super
if
result
=
super
find_or_create_index
find_or_create_
elasticsearch_
index
update_elasticsearch_containers
(
ElasticsearchIndexedNamespace
,
elasticsearch_namespace_ids
)
update_elasticsearch_containers
(
ElasticsearchIndexedNamespace
,
elasticsearch_namespace_ids
)
update_elasticsearch_containers
(
ElasticsearchIndexedProject
,
elasticsearch_project_ids
)
update_elasticsearch_containers
(
ElasticsearchIndexedProject
,
elasticsearch_project_ids
)
end
end
...
@@ -61,13 +61,23 @@ module EE
...
@@ -61,13 +61,23 @@ module EE
current_user_cap
.
nil?
||
current_user_cap
>
previous_user_cap
current_user_cap
.
nil?
||
current_user_cap
>
previous_user_cap
end
end
def
find_or_create_index
def
find_or_create_
elasticsearch_
index
# The order of checks is important. We should not attempt to create a new index
# The order of checks is important. We should not attempt to create a new index
# unless elasticsearch_indexing is enabled
# unless elasticsearch_indexing is enabled
return
unless
application_setting
.
elasticsearch_indexing
return
unless
application_setting
.
elasticsearch_indexing
return
if
::
Gitlab
::
Elastic
::
Helper
.
default
.
index_exists?
return
if
elasticsearch_helper
.
index_exists?
::
Gitlab
::
Elastic
::
Helper
.
default
.
create_empty_index
elasticsearch_helper
.
create_empty_index
rescue
Faraday
::
Error
=>
e
log_error
(
e
)
end
def
elasticsearch_helper
@elasticsearch_helper
||=
::
Gitlab
::
Elastic
::
Helper
.
new
(
client:
elasticsearch_client
)
end
def
elasticsearch_client
::
Gitlab
::
Elastic
::
Client
.
build
(
application_setting
.
elasticsearch_config
)
end
end
end
end
end
end
...
...
ee/changelogs/unreleased/296032_ignore_es_connection_exception.yml
0 → 100644
View file @
101d747d
---
title
:
Ignore connection error when changing the Elasticsearch Server URL
merge_request
:
52645
author
:
type
:
fixed
ee/spec/services/application_settings/update_service_spec.rb
View file @
101d747d
...
@@ -38,7 +38,7 @@ RSpec.describe ApplicationSettings::UpdateService do
...
@@ -38,7 +38,7 @@ RSpec.describe ApplicationSettings::UpdateService do
let
(
:helper
)
{
Gitlab
::
Elastic
::
Helper
.
new
}
let
(
:helper
)
{
Gitlab
::
Elastic
::
Helper
.
new
}
before
do
before
do
allow
(
Gitlab
::
Elastic
::
Helper
).
to
receive
(
:
default
).
and_return
(
helper
)
allow
(
Gitlab
::
Elastic
::
Helper
).
to
receive
(
:
new
).
and_return
(
helper
)
end
end
context
'index creation'
do
context
'index creation'
do
...
@@ -61,6 +61,15 @@ RSpec.describe ApplicationSettings::UpdateService do
...
@@ -61,6 +61,15 @@ RSpec.describe ApplicationSettings::UpdateService do
service
.
execute
service
.
execute
end
end
end
end
context
'when ES service is not reachable'
do
it
'does not throw exception'
do
expect
(
helper
).
to
receive
(
:index_exists?
).
and_raise
(
Faraday
::
ConnectionFailed
,
nil
)
expect
(
helper
).
not_to
receive
(
:create_empty_index
)
expect
{
service
.
execute
}.
not_to
raise_error
end
end
end
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