[MM-61071] Fix errcheck issues in channels/app/admin.go (#28756)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9fee53fb14
Коммит
2d2c039a27
@@ -85,7 +85,6 @@ issues:
|
|||||||
channels/api4/team_test.go|\
|
channels/api4/team_test.go|\
|
||||||
channels/api4/user_test.go|\
|
channels/api4/user_test.go|\
|
||||||
channels/api4/webhook_test.go|\
|
channels/api4/webhook_test.go|\
|
||||||
channels/app/admin.go|\
|
|
||||||
channels/app/app_test.go|\
|
channels/app/app_test.go|\
|
||||||
channels/app/authorization_test.go|\
|
channels/app/authorization_test.go|\
|
||||||
channels/app/auto_responder_test.go|\
|
channels/app/auto_responder_test.go|\
|
||||||
|
|||||||
@@ -70,15 +70,19 @@ func (s *Server) QueryLogs(rctx request.CTX, page, perPage int, logFilter *model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var appErr *model.AppError
|
||||||
serverNames := logFilter.ServerNames
|
serverNames := logFilter.ServerNames
|
||||||
if len(serverNames) > 0 {
|
if len(serverNames) > 0 {
|
||||||
for _, nodeName := range serverNames {
|
for _, nodeName := range serverNames {
|
||||||
if nodeName == "default" {
|
if nodeName == "default" {
|
||||||
AddLocalLogs(rctx, logData, s, page, perPage, nodeName, logFilter)
|
appErr = AddLocalLogs(rctx, logData, s, page, perPage, nodeName, logFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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 {
|
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
|
return releaseInfoResponse, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) ClearLatestVersionCache(rctx request.CTX) {
|
func (a *App) clearLatestVersionCache() error {
|
||||||
latestVersionCache.Remove("latest_version_cache")
|
return latestVersionCache.Remove("latest_version_cache")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,9 +43,10 @@ func TestGetLatestVersion(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("get latest mm version from cache", func(t *testing.T) {
|
t.Run("get latest mm version from cache", func(t *testing.T) {
|
||||||
th.App.ClearLatestVersionCache(th.Context)
|
err := th.App.clearLatestVersionCache()
|
||||||
originalResult, err := th.App.GetLatestVersion(th.Context, ts.URL)
|
require.NoError(t, err)
|
||||||
require.Nil(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.
|
// 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
|
// 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()
|
defer ts.Close()
|
||||||
|
|
||||||
cachedResult, err := th.App.GetLatestVersion(th.Context, updatedServer.URL)
|
cachedResult, appErr := th.App.GetLatestVersion(th.Context, updatedServer.URL)
|
||||||
require.Nil(t, err)
|
require.Nil(t, appErr)
|
||||||
|
|
||||||
require.Equal(t, originalResult.TagName, cachedResult.TagName, "did not get cached result")
|
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) {
|
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) {
|
errorServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
_, err := w.Write([]byte(`
|
_, err := w.Write([]byte(`
|
||||||
|
|||||||
@@ -494,7 +494,6 @@ type AppIface interface {
|
|||||||
CleanUpAfterPostDeletion(c request.CTX, post *model.Post, deleteByID string) *model.AppError
|
CleanUpAfterPostDeletion(c request.CTX, post *model.Post, deleteByID string) *model.AppError
|
||||||
CleanupReportChunks(format string, prefix string, numberOfChunks int) *model.AppError
|
CleanupReportChunks(format string, prefix string, numberOfChunks int) *model.AppError
|
||||||
ClearChannelMembersCache(c request.CTX, channelID string) error
|
ClearChannelMembersCache(c request.CTX, channelID string) error
|
||||||
ClearLatestVersionCache(rctx request.CTX)
|
|
||||||
ClearSessionCacheForAllUsers()
|
ClearSessionCacheForAllUsers()
|
||||||
ClearSessionCacheForAllUsersSkipClusterSend()
|
ClearSessionCacheForAllUsersSkipClusterSend()
|
||||||
ClearSessionCacheForUser(userID string)
|
ClearSessionCacheForUser(userID string)
|
||||||
|
|||||||
@@ -1521,21 +1521,6 @@ func (a *OpenTracingAppLayer) ClearChannelMembersCache(c request.CTX, channelID
|
|||||||
return resultVar0
|
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() {
|
func (a *OpenTracingAppLayer) ClearSessionCacheForAllUsers() {
|
||||||
origCtx := a.ctx
|
origCtx := a.ctx
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.ClearSessionCacheForAllUsers")
|
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.ClearSessionCacheForAllUsers")
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user