MM-49984: Displaying active search backend in system console (#22721)
This will be shown in the system console to let users know which search backend is active. Implemented via adding an extra param in the ping response. https://mattermost.atlassian.net/browse/MM-49984 ```release-note The database section in the system console now has an additional read-only section which shows the active search backend in use. This can be helpful to confirm which is the currently active search engine when there are multiple of them configured. ``` --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4bf31bd227
Коммит
56bf1b695a
@@ -190,6 +190,8 @@ func getSystemPing(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
s["CanReceiveNotifications"] = c.App.SendTestPushNotification(deviceID)
|
||||
}
|
||||
|
||||
s["ActiveSearchBackend"] = c.App.ActiveSearchBackend()
|
||||
|
||||
if s[model.STATUS] != model.StatusOk {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -400,6 +400,7 @@ type AppIface interface {
|
||||
VerifyPlugin(plugin, signature io.ReadSeeker) *model.AppError
|
||||
AccountMigration() einterfaces.AccountMigrationInterface
|
||||
ActivateMfa(userID, token string) *model.AppError
|
||||
ActiveSearchBackend() string
|
||||
AddChannelsToRetentionPolicy(policyID string, channelIDs []string) *model.AppError
|
||||
AddConfigListener(listener func(*model.Config, *model.Config)) string
|
||||
AddDirectChannels(c request.CTX, teamID string, user *model.User) *model.AppError
|
||||
|
||||
@@ -89,6 +89,23 @@ func (a *OpenTracingAppLayer) ActivateMfa(userID string, token string) *model.Ap
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) ActiveSearchBackend() string {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.ActiveSearchBackend")
|
||||
|
||||
a.ctx = newCtx
|
||||
a.app.Srv().Store().SetContext(newCtx)
|
||||
defer func() {
|
||||
a.app.Srv().Store().SetContext(origCtx)
|
||||
a.ctx = origCtx
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0 := a.app.ActiveSearchBackend()
|
||||
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) AddChannelMember(c request.CTX, userID string, channel *model.Channel, opts app.ChannelMemberOpts) (*model.ChannelMember, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.AddChannelMember")
|
||||
|
||||
@@ -60,3 +60,7 @@ func (a *App) PurgeBleveIndexes() *model.AppError {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) ActiveSearchBackend() string {
|
||||
return a.ch.srv.platform.SearchEngine.ActiveEngine()
|
||||
}
|
||||
|
||||
@@ -7795,6 +7795,10 @@
|
||||
"id": "ent.elasticsearch.indexer.index_batch.nothing_left_to_index.error",
|
||||
"translation": "Trying to index a new batch when all the entities are completed"
|
||||
},
|
||||
{
|
||||
"id": "ent.elasticsearch.max_version.app_error",
|
||||
"translation": "Elasticsearch version {{.Version}} is higher than max supported version of {{.MaxVersion}}"
|
||||
},
|
||||
{
|
||||
"id": "ent.elasticsearch.not_started.error",
|
||||
"translation": "Elasticsearch is not started"
|
||||
@@ -7863,10 +7867,6 @@
|
||||
"id": "ent.elasticsearch.search_users.unmarshall_user_failed",
|
||||
"translation": "Failed to decode search results"
|
||||
},
|
||||
{
|
||||
"id": "ent.elasticsearch.start.already_started.app_error",
|
||||
"translation": "Elasticsearch is already started."
|
||||
},
|
||||
{
|
||||
"id": "ent.elasticsearch.start.create_bulk_processor_failed.app_error",
|
||||
"translation": "Failed to create Elasticsearch bulk processor."
|
||||
|
||||
@@ -45,8 +45,19 @@ func (seb *Broker) GetActiveEngines() []SearchEngineInterface {
|
||||
if seb.ElasticsearchEngine != nil && seb.ElasticsearchEngine.IsActive() {
|
||||
engines = append(engines, seb.ElasticsearchEngine)
|
||||
}
|
||||
if seb.BleveEngine != nil && seb.BleveEngine.IsActive() {
|
||||
if seb.BleveEngine != nil && seb.BleveEngine.IsActive() && seb.BleveEngine.IsIndexingEnabled() {
|
||||
engines = append(engines, seb.BleveEngine)
|
||||
}
|
||||
return engines
|
||||
}
|
||||
|
||||
func (seb *Broker) ActiveEngine() string {
|
||||
activeEngines := seb.GetActiveEngines()
|
||||
if len(activeEngines) > 0 {
|
||||
return activeEngines[0].GetName()
|
||||
}
|
||||
if *seb.cfg.SqlSettings.DisableDatabaseSearch {
|
||||
return "none"
|
||||
}
|
||||
return "database"
|
||||
}
|
||||
|
||||
42
server/platform/services/searchengine/searchengine_test.go
Обычный файл
42
server/platform/services/searchengine/searchengine_test.go
Обычный файл
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package searchengine
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/server/platform/services/searchengine/mocks"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestActiveEngine(t *testing.T) {
|
||||
cfg := &model.Config{}
|
||||
cfg.SetDefaults()
|
||||
|
||||
b := NewBroker(cfg)
|
||||
|
||||
esMock := &mocks.SearchEngineInterface{}
|
||||
esMock.On("IsActive").Return(true)
|
||||
esMock.On("GetName").Return("elasticsearch")
|
||||
|
||||
bleveMock := &mocks.SearchEngineInterface{}
|
||||
bleveMock.On("IsActive").Return(true)
|
||||
bleveMock.On("IsIndexingEnabled").Return(true)
|
||||
bleveMock.On("GetName").Return("bleve")
|
||||
|
||||
assert.Equal(t, "database", b.ActiveEngine())
|
||||
|
||||
b.ElasticsearchEngine = esMock
|
||||
assert.Equal(t, "elasticsearch", b.ActiveEngine())
|
||||
|
||||
b.ElasticsearchEngine = nil
|
||||
b.BleveEngine = bleveMock
|
||||
assert.Equal(t, "bleve", b.ActiveEngine())
|
||||
|
||||
b.BleveEngine = nil
|
||||
*b.cfg.SqlSettings.DisableDatabaseSearch = true
|
||||
|
||||
assert.Equal(t, "none", b.ActiveEngine())
|
||||
}
|
||||
Ссылка в новой задаче
Block a user