mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Added license change listener (#24342)
* Added license change listener * Fixed location of adding license listener * Made tests unaffected * Minor refactoring * Changed order of checks to avoid breaking all tests * Using CreateJobOnce to handle HA * Updated context --------- Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
6561f6f4ff
commit
1a49b7e929
@ -555,20 +555,27 @@ func (s *Server) doPostPriorityConfigDefaultTrueMigration() {
|
||||
}
|
||||
|
||||
func (s *Server) doElasticsearchFixChannelIndex(c request.CTX) {
|
||||
s.AddLicenseListener(func(oldLicense, newLicense *model.License) {
|
||||
s.elasticsearchFixChannelIndex(c, newLicense)
|
||||
})
|
||||
|
||||
s.elasticsearchFixChannelIndex(c, s.License())
|
||||
}
|
||||
|
||||
func (s *Server) elasticsearchFixChannelIndex(c request.CTX, license *model.License) {
|
||||
if model.BuildEnterpriseReady != "true" || license == nil || !*license.Features.Elasticsearch {
|
||||
mlog.Debug("Skipping triggering Elasticsearch channel index fix job as build is not Enterprise ready")
|
||||
return
|
||||
}
|
||||
|
||||
// If the migration is already marked as completed, don't do it again.
|
||||
if _, err := s.Store().System().GetByName(model.MigrationKeyElasticsearchFixChannelIndex); err == nil {
|
||||
mlog.Debug("Skipping triggering Elasticsearch channel index fix job as it is already marked completed in database")
|
||||
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(c, model.JobTypeElasticsearchFixChannelIndex, nil); appErr != nil {
|
||||
if _, appErr := s.Jobs.CreateJobOnce(c, model.JobTypeElasticsearchFixChannelIndex, nil); appErr != nil {
|
||||
mlog.Fatal("failed to start job for fixing Elasticsearch channels index", mlog.Err(appErr))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user