* WIP

* Fetched ES index for type checking

* WIP

* Moved migration key to model

* CI

* CI

* Fixed existing tests

* Updated einterface mocks

* CI

* WIP

* Reverted test makefile changes

* Fixed error level

* CI

* Not attempting to launch job if not enterprise ready

* CI

* Fixing job trigger condition

* CI

* Updated eemocks

* CI
Этот коммит содержится в:
Harshil Sharma
2023-04-28 11:11:34 +05:30
коммит произвёл GitHub
родитель 08bb7933aa
Коммит 3db6bb016e
8 изменённых файлов: 83 добавлений и 0 удалений

Просмотреть файл

@@ -50,6 +50,12 @@ func RegisterJobsElasticsearchIndexerInterface(f func(*Server) ejobs.IndexerJobI
jobsElasticsearchIndexerInterface = f
}
var jobsElasticsearchFixChannelIndexInterface func(*Server) ejobs.ElasticsearchFixChannelIndexInterface
func RegisterJobsElasticsearchFixChannelIndexInterface(f func(*Server) ejobs.ElasticsearchFixChannelIndexInterface) {
jobsElasticsearchFixChannelIndexInterface = f
}
var jobsLdapSyncInterface func(*App) ejobs.LdapSyncInterface
func RegisterJobsLdapSyncInterface(f func(*App) ejobs.LdapSyncInterface) {

Просмотреть файл

@@ -559,6 +559,24 @@ func (s *Server) doPostPriorityConfigDefaultTrueMigration() {
}
}
func (s *Server) doElasticsearchFixChannelIndex() {
// If the migration is already marked as completed, don't do it again.
if _, err := s.Store().System().GetByName(model.MigrationKeyElasticsearchFixChannelIndex); err == nil {
return
}
license := s.License()
if model.BuildEnterpriseReady != "true" || license == nil || !*license.Features.Elasticsearch {
mlog.Info("Skipping triggering Elasticsearch channel index fix job as build is not Enterprise ready")
return
}
if _, appErr := s.Jobs.CreateJob(model.JobTypeElasticsearchFixChannelIndex, nil); appErr != nil {
mlog.Fatal("failed to start job for fixing Elasticsearch channels index", mlog.Err(appErr))
return
}
}
func (a *App) DoAppMigrations() {
a.Srv().doAppMigrations()
}
@@ -580,4 +598,5 @@ func (s *Server) doAppMigrations() {
s.doFirstAdminSetupCompleteMigration()
s.doRemainingSchemaMigrations()
s.doPostPriorityConfigDefaultTrueMigration()
s.doElasticsearchFixChannelIndex()
}

Просмотреть файл

@@ -1476,6 +1476,11 @@ func (s *Server) initJobs() {
s.Jobs.RegisterJobType(model.JobTypeElasticsearchPostIndexing, builder.MakeWorker(), nil)
}
if jobsElasticsearchFixChannelIndexInterface != nil {
builder := jobsElasticsearchFixChannelIndexInterface(s)
s.Jobs.RegisterJobType(model.JobTypeElasticsearchFixChannelIndex, builder.MakeWorker(), nil)
}
if jobsLdapSyncInterface != nil {
builder := jobsLdapSyncInterface(New(ServerConnector(s.Channels())))
s.Jobs.RegisterJobType(model.JobTypeLdapSync, builder.MakeWorker(), builder.MakeScheduler())