MM-57018: support reattaching plugins (#26421)

* ProfileImageBytes for EnsureBotOptions

* leverage plugintest.NewAPI

* fix linting

* add UpdateUserRoles to plugin api

* MM-57018: support reattaching plugins

Expose a local-only API for reattaching plugins: instead of the server starting and managing the process itself, allow the plugin to be launched externally (eg within a unit test) and reattach to an existing server instance to provide the unit test with a fully functional RPC API, sidestepping the need for mocking the plugin API in most cases.

In the future, this may become the basis for running plugins in a sidecar container.

Fixes: https://mattermost.atlassian.net/browse/MM-57018

* drop unused supervisor.pid

* factor out checkMinServerVersion

* factor out startPluginServer

* restore missing setPluginState on successful reattach

* avoid passing around a stale registeredPlugin

* inline initializePluginImplementation

* have IsValid return an error

* explicitly close rpcClient

In the case of reattached plugins, the Unix socket won't necessarily disappear leaving the muxBrokers blocked indefinitely. And `Kill()` doesn't do anything if there's no process being managed.

* explicitly detachPlugin

* emphasize gRPC not being supported

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Jesse Hallam
2024-04-11 11:10:25 -04:00
коммит произвёл GitHub
родитель f5ea554c96
Коммит 2230fb6f5f
12 изменённых файлов: 582 добавлений и 72 удалений

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

@@ -4614,6 +4614,10 @@
"id": "api.websocket_handler.server_busy.app_error",
"translation": "Server is busy, non-critical services are temporarily unavailable."
},
{
"id": "api4.plugin.reattachPlugin.invalid_request",
"translation": "Failed to parse request"
},
{
"id": "app.acknowledgement.delete.app_error",
"translation": "Unable to delete acknowledgement."
@@ -6290,6 +6294,10 @@
"id": "app.plugin.not_installed.app_error",
"translation": "Plugin is not installed."
},
{
"id": "app.plugin.reattach.app_error",
"translation": "Failed to reattach plugin"
},
{
"id": "app.plugin.remove.app_error",
"translation": "Unable to delete plugin."
@@ -10142,6 +10150,14 @@
"id": "plugin_api.send_mail.missing_to",
"translation": "Missing TO address."
},
{
"id": "plugin_reattach_request.is_valid.manifest.app_error",
"translation": "Missing manifest"
},
{
"id": "plugin_reattach_request.is_valid.plugin_reattach_config.app_error",
"translation": "Missing plugin reattach config"
},
{
"id": "searchengine.bleve.disabled.error",
"translation": "Error purging Bleve indexes: engine is disabled"