[MM-54132] Use annotated logger for log messages from jobs (#24275)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fcfcbd9909
Коммит
30b12f199b
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||
)
|
||||
|
||||
const EmojisPermissionsMigrationKey = "EmojisPermissionsMigrationComplete"
|
||||
@@ -554,7 +555,7 @@ func (s *Server) doPostPriorityConfigDefaultTrueMigration() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) doElasticsearchFixChannelIndex() {
|
||||
func (s *Server) doElasticsearchFixChannelIndex(c *request.Context) {
|
||||
// If the migration is already marked as completed, don't do it again.
|
||||
if _, err := s.Store().System().GetByName(model.MigrationKeyElasticsearchFixChannelIndex); err == nil {
|
||||
return
|
||||
@@ -566,13 +567,13 @@ func (s *Server) doElasticsearchFixChannelIndex() {
|
||||
return
|
||||
}
|
||||
|
||||
if _, appErr := s.Jobs.CreateJob(model.JobTypeElasticsearchFixChannelIndex, nil); appErr != nil {
|
||||
if _, appErr := s.Jobs.CreateJob(c, model.JobTypeElasticsearchFixChannelIndex, nil); appErr != nil {
|
||||
mlog.Fatal("failed to start job for fixing Elasticsearch channels index", mlog.Err(appErr))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) doCloudS3PathMigrations() {
|
||||
func (s *Server) doCloudS3PathMigrations(c *request.Context) {
|
||||
// This migration is only applicable for cloud environments
|
||||
if os.Getenv("MM_CLOUD_FILESTORE_BIFROST") == "" {
|
||||
return
|
||||
@@ -585,7 +586,7 @@ func (s *Server) doCloudS3PathMigrations() {
|
||||
|
||||
// If there is a job already pending, no need to schedule again.
|
||||
// This is possible if the pod was rolled over.
|
||||
jobs, err := s.Store().Job().GetAllByTypeAndStatus(model.JobTypeS3PathMigration, model.JobStatusPending)
|
||||
jobs, err := s.Store().Job().GetAllByTypeAndStatus(c, model.JobTypeS3PathMigration, model.JobStatusPending)
|
||||
if err != nil {
|
||||
mlog.Fatal("failed to get jobs by type and status", mlog.Err(err))
|
||||
return
|
||||
@@ -594,7 +595,7 @@ func (s *Server) doCloudS3PathMigrations() {
|
||||
return
|
||||
}
|
||||
|
||||
if _, appErr := s.Jobs.CreateJobOnce(model.JobTypeS3PathMigration, nil); appErr != nil {
|
||||
if _, appErr := s.Jobs.CreateJobOnce(c, model.JobTypeS3PathMigration, nil); appErr != nil {
|
||||
mlog.Fatal("failed to start job for migrating s3 file paths", mlog.Err(appErr))
|
||||
return
|
||||
}
|
||||
@@ -606,6 +607,8 @@ func (a *App) DoAppMigrations() {
|
||||
}
|
||||
|
||||
func (s *Server) doAppMigrations() {
|
||||
c := request.EmptyContext(s.Log())
|
||||
|
||||
s.doAdvancedPermissionsMigration()
|
||||
s.doEmojisPermissionsMigration()
|
||||
s.doGuestRolesCreationMigration()
|
||||
@@ -622,6 +625,6 @@ func (s *Server) doAppMigrations() {
|
||||
s.doFirstAdminSetupCompleteMigration()
|
||||
s.doRemainingSchemaMigrations()
|
||||
s.doPostPriorityConfigDefaultTrueMigration()
|
||||
s.doElasticsearchFixChannelIndex()
|
||||
s.doCloudS3PathMigrations()
|
||||
s.doElasticsearchFixChannelIndex(c)
|
||||
s.doCloudS3PathMigrations(c)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user