MM-57152: Get webconn count from the whole cluster (#26813)

We were setting the user status to offline without
checking for connections on other nodes in a cluster.

Now we implement a request-response mechanism for the whole
cluster and we check that before setting a user to offline.

https://mattermost.atlassian.net/browse/MM-57153

```release-note
Fix a bug where the user status would incorrectly be set to offline
without checking for connections in other nodes in an HA cluster.
```

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Этот коммит содержится в:
Agniva De Sarker
2024-04-30 19:28:55 +05:30
коммит произвёл GitHub
родитель 5c11de1373
Коммит 0cee332001
9 изменённых файлов: 153 добавлений и 12 удалений

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

@@ -29,4 +29,7 @@ type ClusterInterface interface {
QueryLogs(page, perPage int) (map[string][]string, *model.AppError)
GetPluginStatuses() (model.PluginStatuses, *model.AppError)
ConfigChanged(previousConfig *model.Config, newConfig *model.Config, sendToOtherServer bool) *model.AppError
// WebConnCountForUser returns the number of active webconn connections
// for a given userID.
WebConnCountForUser(userID string) (int, *model.AppError)
}

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

@@ -301,6 +301,36 @@ func (_m *ClusterInterface) StopInterNodeCommunication() {
_m.Called()
}
// WebConnCountForUser provides a mock function with given fields: userID
func (_m *ClusterInterface) WebConnCountForUser(userID string) (int, *model.AppError) {
ret := _m.Called(userID)
if len(ret) == 0 {
panic("no return value specified for WebConnCountForUser")
}
var r0 int
var r1 *model.AppError
if rf, ok := ret.Get(0).(func(string) (int, *model.AppError)); ok {
return rf(userID)
}
if rf, ok := ret.Get(0).(func(string) int); ok {
r0 = rf(userID)
} else {
r0 = ret.Get(0).(int)
}
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
r1 = rf(userID)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
}
return r0, r1
}
// NewClusterInterface creates a new instance of ClusterInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewClusterInterface(t interface {