DockerCLI/cli-plugins/manager
Laura Brehm ef5e5fa03f
plugins: run plugin with new process group ID
Changes were made in 1554ac3b5f to provide
a mechanism for the CLI to notify running plugin processes that they
should exit, in order to improve the general CLI/plugin UX. The current
implementation boils down to:
1. The CLI creates a socket
2. The CLI executes the plugin
3. The plugin connects to the socket
4. (When) the CLI receives a termination signal, it uses the socket to
   notify the plugin that it should exit
5. The plugin's gets notified via the socket, and cancels it's `cmd.Context`,
   which then gets handled appropriately

This change works in most cases and fixes the issue it sets out to solve
(see: https://github.com/docker/compose/pull/11292) however, in the case
where the user has a TTY attached and the plugin is not already handling
received signals, steps 4+ changes:
4. (When) the CLI receives a termination signal, before it can use the
   socket to notify the plugin that it should exit, the plugin process
   also receives a signal due to sharing the pgid with the CLI

Since we now have a proper "job control" mechanism, we can simplify the
scenarios by executing the plugins with their own process group id,
thereby removing the "double notification" issue and making it so that
plugins can handle the same whether attached to a TTY or not.

In order to make this change "plugin-binary" backwards-compatible, in
the case that a plugin does not connect to the socket, the CLI passes
the signal to the plugin process.

Co-authored-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2024-01-12 13:53:28 -07:00
..
candidate.go remove uses of golang.org/x/sys/execabs 2023-05-26 02:03:45 +02:00
candidate_test.go linting: address else/if/elseif statements found by gocritic 2023-11-20 16:02:16 +01:00
cobra.go load plugin command stubs when required 2023-03-28 06:16:55 +02:00
error.go golangci-lint: revive: enable use-any 2023-11-20 19:52:46 +01:00
error_test.go cli-plugins/manager: TestPluginError: don't use yaml.Marshal 2022-11-17 13:17:51 +01:00
manager.go plugins: run plugin with new process group ID 2024-01-12 13:53:28 -07:00
manager_test.go linting: Consider pre-allocating sliceVar (prealloc) 2023-11-20 16:02:16 +01:00
manager_unix.go plugins: run plugin with new process group ID 2024-01-12 13:53:28 -07:00
manager_windows.go plugins: run plugin with new process group ID 2024-01-12 13:53:28 -07:00
metadata.go cli-plugins: remove deprecated Metadata.Experimental 2023-06-12 14:53:30 +02:00
plugin.go improve plugins listing performance 2023-04-01 16:02:34 +02:00
suffix_unix.go remove pre-go1.17 build-tags 2023-05-05 18:23:03 +02:00
suffix_windows.go Check for `.exe` case insensitively 2019-01-30 13:45:26 +00:00