[MM-31360] downgrade error logs which doesn't break the flow (#16612)

* downgrade error logs which doesn't break the flow

* reflect revivew comments
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2021-01-04 17:02:34 +03:00
коммит произвёл GitHub
родитель c1dd23a3c8
Коммит f9c0c1072f
20 изменённых файлов: 86 добавлений и 118 удалений

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

@@ -81,8 +81,7 @@ func newAWSMarketplaceMeteringService() (*marketplacemetering.MarketplaceMeterin
_, err = creds.Get()
if err != nil {
mlog.Error("session is invalid", mlog.String("error", err.Error()))
return nil, errors.New("cannot obtain credentials")
return nil, errors.Wrap(err, "cannot obtain credentials")
}
return marketplacemetering.New(session.Must(session.NewSession(&aws.Config{
@@ -102,11 +101,11 @@ func (awsm *AwsMeter) GetUserCategoryUsage(dimensions []string, startTime time.T
case model.AWS_METERING_DIMENSION_USAGE_HRS:
userCount, err = awsm.store.User().AnalyticsActiveCountForPeriod(model.GetMillisForTime(startTime), model.GetMillisForTime(endTime), model.UserCountOptions{})
if err != nil {
mlog.Error("Failed to obtain usage data", mlog.String("dimension", dimension), mlog.String("start", startTime.String()), mlog.Int64("count", userCount), mlog.Err(err))
mlog.Warn("Failed to obtain usage data", mlog.String("dimension", dimension), mlog.String("start", startTime.String()), mlog.Int64("count", userCount), mlog.Err(err))
continue
}
default:
mlog.Error("Dimension does not exist!", mlog.String("dimension", dimension))
mlog.Debug("Dimension does not exist!", mlog.String("dimension", dimension))
continue
}

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

@@ -47,7 +47,7 @@ func makeLocalBackend(proxy *ImageProxy) *LocalBackend {
if proxy.Logger != nil {
logger, err := proxy.Logger.StdLogAt(mlog.LevelDebug, mlog.String("image_proxy", "local"))
if err != nil {
mlog.Error("Failed to initialize logger for image proxy", mlog.Err(err))
mlog.Warn("Failed to initialize logger for image proxy", mlog.Err(err))
}
impl.Logger = logger
@@ -55,7 +55,7 @@ func makeLocalBackend(proxy *ImageProxy) *LocalBackend {
baseURL, err := url.Parse(*proxy.ConfigService.Config().ServiceSettings.SiteURL)
if err != nil {
mlog.Error("Failed to set base URL for image proxy. Relative image links may not work.", mlog.Err(err))
mlog.Warn("Failed to set base URL for image proxy. Relative image links may not work.", mlog.Err(err))
} else {
impl.DefaultBaseURL = baseURL
}
@@ -92,7 +92,7 @@ func (backend *LocalBackend) GetImage(w http.ResponseWriter, r *http.Request, im
req, err := http.NewRequest(http.MethodGet, "/"+imageURL, nil)
if err != nil {
// http.NewRequest should only return an error on an invalid URL
mlog.Error("Failed to create request for proxied image", mlog.String("url", imageURL), mlog.Err(err))
mlog.Debug("Failed to create request for proxied image", mlog.String("url", imageURL), mlog.Err(err))
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte{})
@@ -101,7 +101,7 @@ func (backend *LocalBackend) GetImage(w http.ResponseWriter, r *http.Request, im
u, err := url.Parse(imageURL)
if err != nil {
mlog.Error("Failed to parse URL for proxied image", mlog.String("url", imageURL), mlog.Err(err))
mlog.Debug("Failed to parse URL for proxied image", mlog.String("url", imageURL), mlog.Err(err))
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte{})
return

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

@@ -318,7 +318,7 @@ func (worker *BleveIndexerWorker) IndexPostsBatch(progress IndexingProgress) (In
progress.DonePosts = true
progress.LastEntityTime = progress.StartAtTime
} else if progress.LastEntityTime == newLastMessageTime && len(posts) == BatchSize {
mlog.Error("More posts with the same CreateAt time were detected than the permitted batch size. Aborting indexing job.", mlog.Int64("CreateAt", newLastMessageTime), mlog.Int("Batch Size", BatchSize))
mlog.Warn("More posts with the same CreateAt time were detected than the permitted batch size. Aborting indexing job.", mlog.Int64("CreateAt", newLastMessageTime), mlog.Int("Batch Size", BatchSize))
progress.DonePosts = true
progress.LastEntityTime = progress.StartAtTime
} else {
@@ -396,7 +396,7 @@ func (worker *BleveIndexerWorker) IndexChannelsBatch(progress IndexingProgress)
progress.DoneChannels = true
progress.LastEntityTime = progress.StartAtTime
} else if progress.LastEntityTime == newLastChannelTime && len(channels) == BatchSize {
mlog.Error("More channels with the same CreateAt time were detected than the permitted batch size. Aborting indexing job.", mlog.Int64("CreateAt", newLastChannelTime), mlog.Int("Batch Size", BatchSize))
mlog.Warn("More channels with the same CreateAt time were detected than the permitted batch size. Aborting indexing job.", mlog.Int64("CreateAt", newLastChannelTime), mlog.Int("Batch Size", BatchSize))
progress.DoneChannels = true
progress.LastEntityTime = progress.StartAtTime
} else {
@@ -474,7 +474,7 @@ func (worker *BleveIndexerWorker) IndexUsersBatch(progress IndexingProgress) (In
progress.DoneUsers = true
progress.LastEntityTime = progress.StartAtTime
} else if progress.LastEntityTime == newLastUserTime && len(users) == BatchSize {
mlog.Error("More users with the same CreateAt time were detected than the permitted batch size. Aborting indexing job.", mlog.Int64("CreateAt", newLastUserTime), mlog.Int("Batch Size", BatchSize))
mlog.Warn("More users with the same CreateAt time were detected than the permitted batch size. Aborting indexing job.", mlog.Int64("CreateAt", newLastUserTime), mlog.Int("Batch Size", BatchSize))
progress.DoneUsers = true
progress.LastEntityTime = progress.StartAtTime
} else {

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

@@ -686,16 +686,16 @@ func (si *SlackImporter) oldImportUser(team *model.Team, user *model.User) *mode
ruser, nErr := si.store.User().Save(user)
if nErr != nil {
mlog.Error("Error saving user.", mlog.Err(nErr))
mlog.Debug("Error saving user.", mlog.Err(nErr))
return nil
}
if _, err := si.store.User().VerifyEmail(ruser.Id, ruser.Email); err != nil {
mlog.Error("Failed to set email verified.", mlog.Err(err))
mlog.Warn("Failed to set email verified.", mlog.Err(err))
}
if err := si.actions.JoinUserToTeam(team, user, ""); err != nil {
mlog.Error("Failed to join team when importing.", mlog.Err(err))
mlog.Warn("Failed to join team when importing.", mlog.Err(err))
}
return ruser

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

@@ -263,7 +263,7 @@ func (ts *TelemetryService) trackActivity() {
teamCount, err := ts.dbStore.Team().AnalyticsTeamCount(false)
if err != nil {
mlog.Error(err.Error())
mlog.Info("Could not get team count", mlog.Err(err))
}
if ucc, err := ts.dbStore.Channel().AnalyticsTypeCount("", "O"); err == nil {
@@ -1075,42 +1075,42 @@ func (ts *TelemetryService) trackElasticsearch() {
func (ts *TelemetryService) trackGroups() {
groupCount, err := ts.dbStore.Group().GroupCount()
if err != nil {
mlog.Error(err.Error())
mlog.Debug("Could not get group_count", mlog.Err(err))
}
groupTeamCount, err := ts.dbStore.Group().GroupTeamCount()
if err != nil {
mlog.Error(err.Error())
mlog.Debug("Could not get group_team_count", mlog.Err(err))
}
groupChannelCount, err := ts.dbStore.Group().GroupChannelCount()
if err != nil {
mlog.Error(err.Error())
mlog.Debug("Could not get group_channel_count", mlog.Err(err))
}
groupSyncedTeamCount, nErr := ts.dbStore.Team().GroupSyncedTeamCount()
if nErr != nil {
mlog.Error(nErr.Error())
mlog.Debug("Could not get group_synced_team_count", mlog.Err(nErr))
}
groupSyncedChannelCount, nErr := ts.dbStore.Channel().GroupSyncedChannelCount()
if nErr != nil {
mlog.Error(nErr.Error())
mlog.Debug("Could not get group_synced_channel_count", mlog.Err(nErr))
}
groupMemberCount, err := ts.dbStore.Group().GroupMemberCount()
if err != nil {
mlog.Error(err.Error())
mlog.Debug("Could not get group_member_count", mlog.Err(err))
}
distinctGroupMemberCount, err := ts.dbStore.Group().DistinctGroupMemberCount()
if err != nil {
mlog.Error(err.Error())
mlog.Debug("Could not get distinct_group_member_count", mlog.Err(err))
}
groupCountWithAllowReference, err := ts.dbStore.Group().GroupCountWithAllowReference()
if err != nil {
mlog.Error(err.Error())
mlog.Debug("Could not get group_count_with_allow_reference", mlog.Err(err))
}
ts.sendTelemetry(TrackGroups, map[string]interface{}{
@@ -1128,44 +1128,44 @@ func (ts *TelemetryService) trackGroups() {
func (ts *TelemetryService) trackChannelModeration() {
channelSchemeCount, err := ts.dbStore.Scheme().CountByScope(model.SCHEME_SCOPE_CHANNEL)
if err != nil {
mlog.Error(err.Error())
mlog.Debug("Could not get channel_scheme_count", mlog.Err(err))
}
createPostUser, err := ts.dbStore.Scheme().CountWithoutPermission(model.SCHEME_SCOPE_CHANNEL, model.PERMISSION_CREATE_POST.Id, model.RoleScopeChannel, model.RoleTypeUser)
if err != nil {
mlog.Error(err.Error())
mlog.Debug("Could not get create_post_user_disabled_count", mlog.Err(err))
}
createPostGuest, err := ts.dbStore.Scheme().CountWithoutPermission(model.SCHEME_SCOPE_CHANNEL, model.PERMISSION_CREATE_POST.Id, model.RoleScopeChannel, model.RoleTypeGuest)
if err != nil {
mlog.Error(err.Error())
mlog.Debug("Could not get create_post_guest_disabled_count", mlog.Err(err))
}
// only need to track one of 'add_reaction' or 'remove_reaction` because they're both toggled together by the channel moderation feature
postReactionsUser, err := ts.dbStore.Scheme().CountWithoutPermission(model.SCHEME_SCOPE_CHANNEL, model.PERMISSION_ADD_REACTION.Id, model.RoleScopeChannel, model.RoleTypeUser)
if err != nil {
mlog.Error(err.Error())
mlog.Debug("Could not get post_reactions_user_disabled_count", mlog.Err(err))
}
postReactionsGuest, err := ts.dbStore.Scheme().CountWithoutPermission(model.SCHEME_SCOPE_CHANNEL, model.PERMISSION_ADD_REACTION.Id, model.RoleScopeChannel, model.RoleTypeGuest)
if err != nil {
mlog.Error(err.Error())
mlog.Debug("Could not get post_reactions_guest_disabled_count", mlog.Err(err))
}
// only need to track one of 'manage_public_channel_members' or 'manage_private_channel_members` because they're both toggled together by the channel moderation feature
manageMembersUser, err := ts.dbStore.Scheme().CountWithoutPermission(model.SCHEME_SCOPE_CHANNEL, model.PERMISSION_MANAGE_PUBLIC_CHANNEL_MEMBERS.Id, model.RoleScopeChannel, model.RoleTypeUser)
if err != nil {
mlog.Error(err.Error())
mlog.Debug("Could not get manage_members_user_disabled_count", mlog.Err(err))
}
useChannelMentionsUser, err := ts.dbStore.Scheme().CountWithoutPermission(model.SCHEME_SCOPE_CHANNEL, model.PERMISSION_USE_CHANNEL_MENTIONS.Id, model.RoleScopeChannel, model.RoleTypeUser)
if err != nil {
mlog.Error(err.Error())
mlog.Debug("Could not get use_channel_mentions_user_disabled_count", mlog.Err(err))
}
useChannelMentionsGuest, err := ts.dbStore.Scheme().CountWithoutPermission(model.SCHEME_SCOPE_CHANNEL, model.PERMISSION_USE_CHANNEL_MENTIONS.Id, model.RoleScopeChannel, model.RoleTypeGuest)
if err != nil {
mlog.Error(err.Error())
mlog.Debug("Could not get use_channel_mentions_guest_disabled_count", mlog.Err(err))
}
ts.sendTelemetry(TrackChannelModeration, map[string]interface{}{
@@ -1319,7 +1319,7 @@ func (ts *TelemetryService) trackPluginConfig(cfg *model.Config, marketplaceURL
pluginsEnvironment := ts.srv.GetPluginsEnvironment()
if pluginsEnvironment != nil {
if plugins, appErr := pluginsEnvironment.Available(); appErr != nil {
mlog.Error("Unable to add plugin versions to telemetry", mlog.Err(appErr))
mlog.Warn("Unable to add plugin versions to telemetry", mlog.Err(appErr))
} else {
// If marketplace request failed, use predefined list
if marketplacePlugins == nil {

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

@@ -81,25 +81,25 @@ func getCurrentVersionTgzUrl() string {
func verifySignature(filename string, sigfilename string, publicKey string) error {
keyring, err := openpgp.ReadArmoredKeyRing(bytes.NewReader([]byte(publicKey)))
if err != nil {
mlog.Error("Unable to load the public key to verify the file signature", mlog.Err(err))
mlog.Debug("Unable to load the public key to verify the file signature", mlog.Err(err))
return NewInvalidSignature()
}
mattermost_tar, err := os.Open(filename)
if err != nil {
mlog.Error("Unable to open the Mattermost .tar file to verify the file signature", mlog.Err(err))
mlog.Debug("Unable to open the Mattermost .tar file to verify the file signature", mlog.Err(err))
return NewInvalidSignature()
}
signature, err := os.Open(sigfilename)
if err != nil {
mlog.Error("Unable to open the Mattermost .sig file verify the file signature", mlog.Err(err))
mlog.Debug("Unable to open the Mattermost .sig file verify the file signature", mlog.Err(err))
return NewInvalidSignature()
}
_, err = openpgp.CheckDetachedSignature(keyring, mattermost_tar, signature)
if err != nil {
mlog.Error("Unable to verify the Mattermost file signature", mlog.Err(err))
mlog.Debug("Unable to verify the Mattermost file signature", mlog.Err(err))
return NewInvalidSignature()
}
return nil
@@ -157,8 +157,7 @@ func canIUpgrade() error {
func CanIUpgradeToE0() error {
if err := canIUpgrade(); err != nil {
mlog.Error("Unable to upgrade from TE to E0", mlog.Err(err))
return err
return errors.Wrap(err, "unable to upgrade from TE to E0")
}
if model.BuildEnterpriseReady == "true" {
mlog.Warn("Unable to upgrade from TE to E0. The server is already running E0.")
@@ -252,12 +251,14 @@ func download(url string, limit int64) (string, error) {
func getFilePermissionsOrDefault(filename string, def os.FileMode) os.FileMode {
file, err := os.Open(filename)
if err != nil {
mlog.Error("Unable to get the file permissions", mlog.String("filename", filename), mlog.Err(err))
mlog.Warn("Unable to get the file permissions", mlog.String("filename", filename), mlog.Err(err))
return def
}
defer file.Close()
fileStats, err := file.Stat()
if err != nil {
mlog.Error("Unable to get the file permissions", mlog.String("filename", filename), mlog.Err(err))
mlog.Warn("Unable to get the file permissions", mlog.String("filename", filename), mlog.Err(err))
return def
}
return fileStats.Mode()