diff --git a/server/.golangci.yml b/server/.golangci.yml index d57892f9f63e4..1e6e67401bfd5 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -85,7 +85,6 @@ issues: channels/api4/team_test.go|\ channels/api4/user_test.go|\ channels/api4/webhook_test.go|\ - channels/app/admin.go|\ channels/app/app_test.go|\ channels/app/authorization_test.go|\ channels/app/auto_responder_test.go|\ diff --git a/server/channels/app/admin.go b/server/channels/app/admin.go index fce9a7f2b2d15..d23c6d3691879 100644 --- a/server/channels/app/admin.go +++ b/server/channels/app/admin.go @@ -70,15 +70,19 @@ func (s *Server) QueryLogs(rctx request.CTX, page, perPage int, logFilter *model } } + var appErr *model.AppError serverNames := logFilter.ServerNames if len(serverNames) > 0 { for _, nodeName := range serverNames { if nodeName == "default" { - AddLocalLogs(rctx, logData, s, page, perPage, nodeName, logFilter) + appErr = AddLocalLogs(rctx, logData, s, page, perPage, nodeName, logFilter) } } } else { - AddLocalLogs(rctx, logData, s, page, perPage, serverName, logFilter) + appErr = AddLocalLogs(rctx, logData, s, page, perPage, serverName, logFilter) + } + if appErr != nil { + return nil, appErr } if s.platform.Cluster() != nil && *s.Config().ClusterSettings.Enable { @@ -237,6 +241,6 @@ func (a *App) GetLatestVersion(rctx request.CTX, latestVersionUrl string) (*mode return releaseInfoResponse, nil } -func (a *App) ClearLatestVersionCache(rctx request.CTX) { - latestVersionCache.Remove("latest_version_cache") +func (a *App) clearLatestVersionCache() error { + return latestVersionCache.Remove("latest_version_cache") } diff --git a/server/channels/app/admin_test.go b/server/channels/app/admin_test.go index f7d5d940e7e16..5277eda97fd93 100644 --- a/server/channels/app/admin_test.go +++ b/server/channels/app/admin_test.go @@ -43,9 +43,10 @@ func TestGetLatestVersion(t *testing.T) { }) t.Run("get latest mm version from cache", func(t *testing.T) { - th.App.ClearLatestVersionCache(th.Context) - originalResult, err := th.App.GetLatestVersion(th.Context, ts.URL) - require.Nil(t, err) + err := th.App.clearLatestVersionCache() + require.NoError(t, err) + originalResult, appErr := th.App.GetLatestVersion(th.Context, ts.URL) + require.Nil(t, appErr) // Call same function but mock the GET request to return a different result. // We are hoping the function will use the cache instead of making the GET request @@ -68,14 +69,16 @@ func TestGetLatestVersion(t *testing.T) { })) defer ts.Close() - cachedResult, err := th.App.GetLatestVersion(th.Context, updatedServer.URL) - require.Nil(t, err) + cachedResult, appErr := th.App.GetLatestVersion(th.Context, updatedServer.URL) + require.Nil(t, appErr) require.Equal(t, originalResult.TagName, cachedResult.TagName, "did not get cached result") }) t.Run("get latest mm version error from external", func(t *testing.T) { - th.App.ClearLatestVersionCache(th.Context) + err := th.App.clearLatestVersionCache() + require.NoError(t, err) + errorServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) _, err := w.Write([]byte(` diff --git a/server/channels/app/app_iface.go b/server/channels/app/app_iface.go index 60e7d2b9c0163..ae25f54191ec6 100644 --- a/server/channels/app/app_iface.go +++ b/server/channels/app/app_iface.go @@ -494,7 +494,6 @@ type AppIface interface { CleanUpAfterPostDeletion(c request.CTX, post *model.Post, deleteByID string) *model.AppError CleanupReportChunks(format string, prefix string, numberOfChunks int) *model.AppError ClearChannelMembersCache(c request.CTX, channelID string) error - ClearLatestVersionCache(rctx request.CTX) ClearSessionCacheForAllUsers() ClearSessionCacheForAllUsersSkipClusterSend() ClearSessionCacheForUser(userID string) diff --git a/server/channels/app/opentracing/opentracing_layer.go b/server/channels/app/opentracing/opentracing_layer.go index 1a7dec97fb240..0a3836819b25c 100644 --- a/server/channels/app/opentracing/opentracing_layer.go +++ b/server/channels/app/opentracing/opentracing_layer.go @@ -1521,21 +1521,6 @@ func (a *OpenTracingAppLayer) ClearChannelMembersCache(c request.CTX, channelID return resultVar0 } -func (a *OpenTracingAppLayer) ClearLatestVersionCache(rctx request.CTX) { - origCtx := a.ctx - span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.ClearLatestVersionCache") - - a.ctx = newCtx - a.app.Srv().Store().SetContext(newCtx) - defer func() { - a.app.Srv().Store().SetContext(origCtx) - a.ctx = origCtx - }() - - defer span.Finish() - a.app.ClearLatestVersionCache(rctx) -} - func (a *OpenTracingAppLayer) ClearSessionCacheForAllUsers() { origCtx := a.ctx span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.ClearSessionCacheForAllUsers")