Commit Graph

152 Commits

Author SHA1 Message Date
Nick Misasi
4b6e73c1c4 [MM-35625] Add controller for changing cloud subscription (#17676)
* Add a controller for changing subscription

* Changes for PR

* Another change

* Fix pipeline

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-05-27 09:12:47 -04:00
Scott Bishel
2f33b52d8a check authdata for different format (#17577)
* check authdata for different format

* add mocks, fix lint

* rename function

* update auth-data with new format

* update assert

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-05-24 09:04:20 -06:00
Ibrahim Serdar Acikgoz
5ea06e51d0 Migrate to stateless app.App (#17542)
* add request context

* move initialialization to server

* use app interface instead of global app functions

* remove app context from webconn

* cleanup

* remove duplicated services

* move context to separate package

* remove finalize init method and move content to NewServer function

* restart workers and schedulers after adding license for tests

* reflect review comments

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-05-11 13:00:44 +03:00
Max Erenberg
9f4902e188 [MM-33908] Resync LDAP Groups to Teams and Channels (#17372)
* add includeRemovedMembers flag

* fix API call in client4.go

* remove check for 'since'

* add comments

* run make app-layers

* re-run CI tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-05-04 12:37:36 -04:00
Agniva De Sarker
21776870d6 MM-34878: Add metrics for websocket reconnects (#17522)
* MM-34878: Add metrics for websocket reconnects

Added two new metrics to track successful websocket drain
and dead queue misses.

```release-note
NONE
```

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

* remove TODO line
2021-04-29 19:42:48 +05:30
Claudio Costa
6af032d06a [MM-35077] Add basic support for plugin intra-cluster communication (#17495)
* Add basic support for plugin intra-cluster communication

* Some renaming for added clarity

* Allow sending cluster event to specific nodes

* Improve naming and documentation

* Improve logging
2021-04-28 19:59:32 +02:00
Max Erenberg
f36f5c74b1 Mm 30807 granular data retention scaffold (#17464) 2021-04-20 13:16:40 -04:00
Agniva De Sarker
e0efdd708b Revert "Mm 30807 granular data retention scaffold (#16891)" (#17437)
This reverts commit 3ea75332e7.
2021-04-18 22:41:50 +05:30
Max Erenberg
3ea75332e7 Mm 30807 granular data retention scaffold (#16891)
create the necessary tables, models and APIs for the granular data retention policy feature
2021-04-16 11:32:09 -04:00
Scott Bishel
e8b710f7fe Update group sync to work with AD - SAML ids (#17108)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-04-13 15:30:19 -06:00
Haardik Dharma
343c51830f Fix initialism errors (PR-2) (#17032)
* Fix initialism errors

* Fix check-mocks test

* Revert mlog and filestore packages

* Update plugin_hooks_test.go

* Update opentracinglayer.go

* Regenerate mocks and check store layers

* Revert plugin's context changes

* Update context.go

* Update plugin_requests.go

* Update plugin_hooks_test.go

* Regenerate mocks

* Regenerate mocks and store layers

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-04-03 12:43:22 +05:30
Doug Lauder
02196e04fa MM-27493 Shared channels (MVP) (#17301)
Remote Cluster Service
- provides ability for multiple Mattermost cluster instances to create a trusted connection with each other and exchange messages
- trusted connections are managed via slash commands (for now)
- facilitates features requiring inter-cluster communication, such as Shared Channels
Shared Channels Service
- provides ability to shared channels between one or more Mattermost cluster instances (using trusted connection)
- sharing/unsharing of channels is managed via slash commands (for now)
2021-04-01 13:44:56 -04:00
Allan Guwatudde
489eaa4605 [MM-32639] - Resend user invite emails (#17113)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-31 13:20:53 -04:00
Agniva De Sarker
7b1dee4936 MM-33818: Add replica lag metric (#17148)
* MM-33818: Add replica lag metric

We add two new metrics for monitoring replica lag:
- Monitor absolute lag based on binlog distance/transaction queue length.
- Monitor time taken for the replica to catch up.

To achieve this, we add a config setting to run a user defined SQL query
on the database.

We need to specify a separate datasource field as part of the config because
in some databases, querying the replica lag value requires elevated credentials
which are not needed for usual running of the application, and can even be a security risk.

Arguably, a peculiar part of the design is the requirement of the query output to be in a (node, value)
format. But since from the application, the SQL query is a black box and the user can set any query
they want, we cannot, in any way templatize this.

And as an extra note, freno also does it in a similar way.

The last bit is because we need to have a separate datasources, now we consume one extra connection
rather than sharing it with the pool. This is an unfortunate result of the design, and while one extra
connection doesn't make much of a difference in a single-tenant scenario. It does make so, in a multi-tenant scenario.
But in a multi-tenant scenario, the expectation would already be to use a connection pool. So this
is not a big concern.

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

```release-note
Two new gauge metrics were added:
mattermost_db_replica_lag_abs and mattermost_db_replica_lag_time, both
containing a label of "node", signifying which db host is the metric from.

These metrics signify the replica lag in absolute terms and in the time dimension
capturing the whole picture of replica lag.

To use these metrics, a separate config section ReplicaLagSettings was added
under SqlSettings. This is an array of maps which contain three keys: DataSource,
QueryAbsoluteLag, and QueryTimeLag. Each map entry is for a single replica instance.

DataSource contains the DB credentials to connect to the replica instance.

QueryAbsoluteLag is a plain SQL query that must return a single row of which the first column
must be the node value of the Prometheus metric, and the second column must be the value of the lag.

QueryTimeLag is the same as above, but used to measure the time lag.

As an example, for AWS Aurora instances, the QueryAbsoluteLag can be:

select server_id, highest_lsn_rcvd-durable_lsn as bindiff from aurora_global_db_instance_status() where server_id=<>

and QueryTimeLag can be:

select server_id, visibility_lag_in_msec from aurora_global_db_instance_status() where server_id=<>

For MySQL Group Replication, the absolute lag can be measured from the number of pending transactions
in the applier queue:

select member_id, count_transaction_remote_in_applier_queue FROM performance_schema.replication_group_member_stats where member_id=<>

Overall, what query to choose is left to the administrator, and depending on the database and need, an appropriate
query can be chosen.
```

* Trigger CI

* Fix tests

* address review comments

* Remove t.Parallel

It was spawning too many connections,
and overloading the docker container.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-29 21:35:24 +05:30
Max Erenberg
6a77e24adc MM-28090 User settings api when ldap sync (#16822)
Automatic Merge
2021-03-22 19:02:16 +01:00
Ibrahim Serdar Acikgoz
f31a9ed1a8 [MM-31132] app/server: add pprof endpoint (#17001)
* app/server: add pprof endpoint

* reflect review comments

* make metrics link conditional

* app/server: add metrics server setup to licence listeners

* refactor a bit

* trigger CI

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-12 14:23:24 +03:00
Mario de Frutos Dieguez
5203fc8608 [MM-28694] Add MM User information in the CWS request headers (#15824)
* Include user data in the cloud endpoints

Those headers will include the user ID and Email so we can use them
in CWS

* Removed AppError from enterprise/cloud

We're removing the AppError from all the places that don't belong
to the app or api4 packages.

* Remove unused i18n strings

* Move it to the server init of enterprise

Also moved the initialization of the enterprise part in the server after the store is initialized

* Initialize after the store is set in NewServer

The ideal way to do it should be to move the initEnterprise call after
the store is set but that would lead to undesired side-effects so we
initialize the cloud part alone.

Signed-off-by: Mario de Frutos <mario@defrutos.org>
2021-03-05 09:23:39 +01:00
Hossein
01f264cd62 [MM-31790] Support Packet Generation BACKEND (#16667)
* init commit

* clean up the code

* make mocks

* fix translations

* mocks and lint fixes

* add tests

* little fixes

* Update i18n/en.json

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* Update i18n/en.json

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* Update i18n/en.json

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* Update i18n/en.json

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* Update i18n/en.json

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* Address Comments

* fix i18n

* update api endpoint

* add enable file and file level for conditional show of banner

* Address Comments

* Make it more clear about returns

* Create zip file utility function

* update en.json

* address comments

* write tests

* check for data in test

* remove warning string

* Correct expected and actual

* set database through environment variables

* reset environment variable at end of test

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
2021-02-01 15:18:52 -05:00
Jesse Hallam
f8caa6c841 Job metrics & dynamic Grafana annotations (#16650)
* docker: prometheus and grafana for development

Add prometheus and grafana docker configuration when developing with access to the enterprise repository. This simplifies the setup for developers adding new metrics or even examining events from their development server. The services are disabled by default when no enterprise source is detected.

Grafana is provisioned automatically with the Prometheus datasource, as well as the canonical dashboards used with Mattermost. Furthermore, no authentication is required to access Grafana to simplify access from a development environment. The default home dashboard is customized to automatically show links to the provisioned dashboards. Dashboards can be saved, and login remains available via the default `admin/admin` credentials (which initiates a password reset), but no dashboard or system configuration is (currently) persisted if the container is destroyed.

Linux requires slightly special handling (well, really it's Docker for MacOS/Windows), in that `host.docker.internal` is the canonical way to resolve the host on MacOS/Windows, but on Linux it's usually sufficient to just use `localhost`. Until https://github.com/docker/for-linux/issues/264 is resolved, this PR includes code to customize the Prometheus configuration to point at the required address for the running platform.

* metrics: track active jobs by type

* metrics: active jobs chart

* metrics: server start and job annotations

* Update build/docker-compose.common.yml

Co-authored-by: Claudio Costa <cstcld91@gmail.com>

* prometheus: resolve docker host via 172.17.0.1 instead

* skip enabling prometheus and grafana by default

* handle JOB_STATUS_ERROR and JOB_STATUS_CANCELED end states

* handle nil srv.metrics

* lookup job to determine type for metrics

* mocked unit tests for jobs

* goimports lint fixes

* missing license

* add instance to server start tag

* filter annotations by selected instance

Co-authored-by: Claudio Costa <cstcld91@gmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-01-20 15:43:02 -04:00
Jesús Espino
2a63b5552a Add search engine support for files (#16190)
* Add search engine support for files

* Fixing i18n

* Fix golangci-lint

* Fix consistency problem in the Search receiver functio of the SqlFileStore

* Fixing some tests

* Fixing test

* Apply suggestions from code review

Co-authored-by: Mario de Frutos Dieguez <mario@defrutos.org>

* Addressing PR review comments

* Removing some empty lines

* Address PR review comments

* Fixing problem after merge master

* Fixing spelling problem

* Add missed translations

* Fixing certain global variable usages after merge master

* Fixing some constants usage

* Fixing goimports order

Co-authored-by: Mario de Frutos Dieguez <mario@defrutos.org>
2021-01-11 15:14:16 +01:00
Agniva De Sarker
e89b26e8f3 goimports (#16640)
* format using `goimports -local github.com/mattermost/mattermost-server/v5 -w`

* added goimports lint check to .golangci.yml

* format using `goimports -local github.com/mattermost/mattermost-server/v5 -w` for a corner case

* make app-layers, *-mocks and store-layers for ci check

Co-authored-by: Mahmudul Haque <mahmudulhaque@protonmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-01-07 22:42:43 +05:30
Scott Bishel
8496cb6977 update einterface mocks (#16555) 2020-12-15 08:50:50 -07:00
Scott Bishel
f548ecbee1 MM-27688-OpenId Connect (#16222)
* implement openid connect

* update error strings

* handle OpenIdSetting.Secret as FAKE SETTING

* add openid to telemetry

* update config defaults, add telemetry

* fix bug with Office365

* Retrieve Office365 AuthData from IdToken

* fix linter

* add feature flag, reset defaults for config

* fix build error

* fix unit tests

* add authentication permission to Feature
Flags

* turn off feature flag

* set default button color

* set default button color only on openid

* fix for merging FeatureFlags in config

* remove feature flag

* revert config changes

* remove debug statements

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-12-08 19:58:37 -07:00
Eli Yukelzon
86e228b6c6 MM-30558 - Add unreadReplies and unreadMentions to thread membership (#16304) 2020-12-06 10:02:53 +02:00
Agniva De Sarker
4cdf239139 MM-29107: Fix race in LDAP login (#16239)
* MM-29107: Fix race in LDAP login

We remove the goroutine to make things synchronous.

This removes the race and makes things more reliable.
It is already tested by TestLogin in ldap_test.go in -race mode.

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

```release-note
NONE
```

* Address review comments

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-11-20 18:07:31 +05:30
Nick Misasi
1d15900f84 [MM-29999] User Limit Email Notifications (Part 2) (#16220)
* Adding files commiting to do something else

* Stashing to merge master

* Adding files, commit of working code, pre-test

* Changing up logic according to new conversations, adding template and functions for 7 day and 14 day emails

* Add subscription active check

* Add a comment around subscription status

* Fix i18n

* Update jobs/cloud/worker.go

Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>

* Add a check for cloud license and exit early

* remove log

* Update jobs/cloud/worker.go

Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>

* Remove case for 91st day

* Change var name

* Fix i18n

* Change value for dates in email

* Add email template and send logic for support email on 30th day of arrears

* Fix EETests?

* add one to the day so the count starts on first day of next cycle

* use the license for the enabled check

* Moved scheduler and worker into enterprise

* Add the user count to the support email

* remove a line

* Use the date for the 14 day email

* Fix for design review

* More font changes

* Fixes for PR

* Change feature flag name

* Add cloud_interface to einterfaces/jobs

* Add back & for running job server

* Remove unused constant

Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-11-12 09:07:31 -05:00
Nick Misasi
714435fc4c Pass the filename from CWS on to the client (#16203) 2020-11-03 13:11:18 -05:00
Eli Yukelzon
fe352ab57f MM-29703 Mark threads as read when channels are marked (#15994)
Co-authored-by: Jesús Espino <jespinog@gmail.com>
2020-10-30 17:00:21 +02:00
Mario de Frutos Dieguez
b68f171162 [MM-29157] Cloud invoices logic (#16056)
* Cloud invoices logic

This commit includes all the code needed to get and print invoices
from CWS
2020-10-26 18:17:55 +01:00
Scott Bishel
f46661d7a9 MM-28882:ignore guest ldap sync (#15936)
* add ignoreGuestsLdapSync to config, update interface

* update interface

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-21 20:12:12 -06:00
Devin Binnie
73a1c95137 [MM-28218] API hookup for updating company info and address in MM app (#15974) 2020-10-20 11:46:58 +02:00
Ibrahim Serdar Acikgoz
c05ee81c9f [MM-28125] einterface/oauthprovide: return parsing errors (#15426)
* einterface/oauthprovide: return parsing errors

* Update app/oauth.go

* reflect review comments

* fix var name error

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-19 18:07:20 +03:00
Devin Binnie
ebd3e6aa49 [MM-28217] Server API to serve up cloud customer information (#15656)
* [MM-28217] Server API to serve up cloud customer information

* Added missing client4 method

* merge'd

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-05 08:46:52 -04:00
Devin Binnie
2403aae0c4 [MM-28211] API pass-thru to the CWS for getting subscription (#15666)
* API pass-thru to the CWS for getting subscription

* Remove use of parameter in favour of env var

* Remove unnecessary param

* Removed unnecessary fields and added client4 method

* Some cleanup

* Translation fix

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-01 13:14:48 -04:00
Maria A Nunez
50e37068b5 MM-27147 - /cloud api endpoints (#15626) 2020-09-28 12:18:47 -04:00
Agniva De Sarker
85b434c50d Revert "MM-27147 - /cloud api endpoints (#15428)" (#15615)
This reverts commit 88aed7ec9e.
2020-09-28 09:06:55 +02:00
Maria A Nunez
88aed7ec9e MM-27147 - /cloud api endpoints (#15428) 2020-09-25 21:03:21 -04:00
Scott Bishel
eba38625eb Implement LDAP Certificate (#15361)
* Implement LDAP Certificate

* add diagnostics and translations

* update from code review

* pass pointer to update pict function

* pass object to first function

* remove debug log messages

* update test to add localmode test

* update lint errors

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-09-14 12:53:42 -06:00
Eli Yukelzon
f4ccc7061c MM-27199 - Add metrics to MM server for total enabled user count (#15116)
* Add metrics to MM server for total enabled user count and include installation ID from a new env var

* diagnostics context

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-09-07 09:26:25 -04:00
Doug Lauder
05f1f35a00 MM-22786 enterprise metrics for logging (#15313)
Adds metrics for logging engine which are collected by Prometheus.
- current queue level(s)
- rate of logging records emitted
- rate of logging errors
2020-09-01 10:29:29 -04:00
Scott Bishel
23e306bc3a add function to LdapInterface (#14761)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-24 10:01:31 -06:00
Agniva De Sarker
3cf05efdd9 MM-25404: Add GetHealthScore metric for the cluster (#14767)
* MM-25404: Add GetHealthScore metric for the cluster

This PR adds the necessary function to the cluster interface
so that they can be called from App code.

* Add mocks

* Remove fakeapp

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-06-24 18:46:33 +05:30
Doug Lauder
b317ee5cf2 MM-25394 session expired push notifications (#14732)
* new job type created that checks for expired mobile sessions and pushes notifications.

* only send session expired notifications if ExtendSessionLengthWithActivity is enabled.

* includes schema change:  field added to Sessions table
2020-06-17 14:47:54 -04:00
Scott Bishel
e8081b7a0f MM24459: Implement ldap picture sync (#14540)
* implement ldap picture sync

* add testing timeout, and no change

* Revert "add testing timeout, and no change"

This reverts commit 765621a729.

* update app-layer

* updates from code review

* update app-layers

* remove debug statements

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-19 08:25:52 -06:00
Agniva De Sarker
624980ff54 MM-25005: Remove HttpRequestsDuration bucket (#14520)
* MM-25005: Remove HttpRequestsDuration bucket

The ApiTimesHistograms already captures what HttpRequestsDuration does.
And it's more granular than that. So there's no need to duplicate stuff.
Let's remove this one.

* Updating resource class to xlarge

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Jason Deland <jaydeland@gmail.com>
2020-05-14 10:53:55 +05:30
Scott Bishel
1031e27fd8 MM-23038: Compliance Report Fixes (#14242)
* add warning count as return value

* add warning count as return value

* fix file name

* update mock

* add setting warning to db

* replace wrongly removed string

* add dummy function to see if it will build

* remove dummy function

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-07 14:12:47 -06:00
Mario de Frutos Dieguez
aafea55976 MM-23131 Include HTTP status code in the metrics (#14240)
* ResponseWriter wrapper to get status code

For our metrics, we need the status code returned by a request
so this wrapper includes a new method StatusCode() that includes
the desired code

* Shadow the responsewriter variable in the handlers

In order to avoid confusion to people deciding what variable to use.
I've also changed the tests to reflect this change and added a new
one that checks the Flush method works
2020-04-14 14:15:00 +02:00
Jesús Espino
c66e182b08 Adding the new search engine abstraction (#13304)
* WIP

* Adding bleve to go modules

* WIP

* Adding missing files from searchengine implementation

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* User and channel indexing and searches implemented

* Make bleve tests run with in-memory indexes

* Implement post index and deletion tests

* Initial commits for the search layer

* Removing unnecesary indexing

* WIP

* WIP

* More fixes for tests

* Adding the search layer

* Finishing the migration of searchers to the layer

* Removing unnecesary code

* Allowing multiple engines active at the same time

* WIP

* Add simple post search

* Print information when using bleve

* Adding some debugging to understand better how the searches are working

* Making more dynamic config of search engines

* Add post search basics

* Adding the Purge API endpoint

* Fixing bleve config updates

* Adding missed file

* Regenerating search engine mocks

* Adding missed v5 to modules imports

* fixing i18n

* Fixing some test around search engine

* Removing all bleve traces

* Cleaning up the vendors directory and go.mod/go.sum files

* Regenerating timer layer

* Adding properly the license

* Fixing govet shadow error

* Fixing some tests

* Fixing TestSearchPostsFromUser

* Fixing another test

* Fixing more tests

* Fixing more tests

* Removing SearchEngine redundant text from searchengine module code

* Fixing some reindexing problems in members updates

* Fixing tests

* Addressing PR comments

* Reverting go.mod and go.sum

* Addressing PR comments

* Fixing tests compilation

* Fixing govet

* Adding search engine stop method

* Being more explicit on where we use includeDeleted

* Adding GetSqlSupplier test helper method

* Mocking elasticsearch start function

* Fixing tests

Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-03-13 15:33:18 +01:00
Mario de Frutos Dieguez
ee86413cdd Include websocket users metric (#14020)
This commit adds new metrics to know the number of registered users
we have in every WebSocket broadcasts hub
2020-03-10 10:15:56 +01:00
Mario de Frutos Dieguez
75197d291a Added Websocket's broadcast queue load metrics (#13935)
Now we send metrics when the websocket's broadcast queue receive or
consume a message from the queue
2020-02-28 11:44:56 +01:00