From e9089acb6cde53f3143c0a6f6321accddab29f9e Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Wed, 13 Feb 2019 15:17:59 +0000 Subject: [PATCH] Logs the errors when indexing and deleting posts with elasticsearch (#10282) --- app/post.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/post.go b/app/post.go index c8ec9f6817..85e882ee62 100644 --- a/app/post.go +++ b/app/post.go @@ -263,7 +263,9 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo esInterface := a.Elasticsearch if esInterface != nil && *a.Config().ElasticsearchSettings.EnableIndexing { a.Srv.Go(func() { - esInterface.IndexPost(rpost, channel.TeamId) + if err := esInterface.IndexPost(rpost, channel.TeamId); err != nil { + mlog.Error("Encountered error indexing post", mlog.String("post_id", post.Id), mlog.Err(err)) + } }) } @@ -496,7 +498,9 @@ func (a *App) UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model mlog.Error(fmt.Sprintf("Couldn't get channel %v for post %v for Elasticsearch indexing.", rpost.ChannelId, rpost.Id)) return } - esInterface.IndexPost(rpost, rchannel.Data.(*model.Channel).TeamId) + if err := esInterface.IndexPost(rpost, rchannel.Data.(*model.Channel).TeamId); err != nil { + mlog.Error("Encountered error indexing post", mlog.String("post_id", post.Id), mlog.Err(err)) + } }) } @@ -680,7 +684,9 @@ func (a *App) DeletePost(postId, deleteByID string) (*model.Post, *model.AppErro esInterface := a.Elasticsearch if esInterface != nil && *a.Config().ElasticsearchSettings.EnableIndexing { a.Srv.Go(func() { - esInterface.DeletePost(post) + if err := esInterface.DeletePost(post); err != nil { + mlog.Error("Encountered error deleting post", mlog.String("post_id", post.Id), mlog.Err(err)) + } }) }