You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use a tctl-authorization-plugin with the tctl CLI for our Temporal clusters. We had reports from our users that many instances of our plugin was left running in the background after they had completed running their commands.
After some investigation I realized that the plugin server and client were handled correctly when CLI commands were completing successfully. However whenever the CLI commands were returning an error (specifically exiting with non-zero) the plugin server was left running in the background (aka "leaking").
When tctl exits with an error it calls os.Exit(1). This results in the process being immediately terminated without calling any of the deferred functions. This means that the stopPlugins function is not called, leaving the plugin server running.
Example command:
$ tctl wf show
Error: Option workflow_id is required
exit status 1
More in depth description
Stepping through the CLI application we can see that:
Exit causes the current program to exit with the given status code. Conventionally, code zero indicates success, non-zero an error. The program terminates immediately; deferred functions are not run.
For portability, the status code should be in the range [0, 125].
This means that the deferred stopPlugins function is never called and the plugin server is left running.
Note: I'm intentionally eliding the plugin setup, GRPC interceptor, etc. since it works as expected on the happy path.
Minimal Reproduction
I don't know of a minimal authorization plugin that I can run so this is a little more vague than I would like. Apologies in advance.
The Temporal environment variables (somewhat redacted):
What are you really trying to do?
We use a
tctl-authorization-plugin
with thetctl
CLI for our Temporal clusters. We had reports from our users that many instances of our plugin was left running in the background after they had completed running their commands.After some investigation I realized that the plugin server and client were handled correctly when CLI commands were completing successfully. However whenever the CLI commands were returning an error (specifically exiting with non-zero) the plugin server was left running in the background (aka "leaking").
I am very familiar with Hashicorp's go-plugin framework.
Describe the bug
When
tctl
exits with an error it callsos.Exit(1)
. This results in the process being immediately terminated without calling any of thedefer
red functions. This means that thestopPlugins
function is not called, leaving the plugin server running.Example command:
$ tctl wf show Error: Option workflow_id is required exit status 1
More in depth description
Stepping through the CLI application we can see that:
ShowHistory(c)
getRequiredOption(c, FlagWorkflowID)
ErrorAndExit(...)
since the value hasn't been setosExit(1)
os.Exit
Quoting the Go documentation:
This means that the deferred
stopPlugins
function is never called and the plugin server is left running.Note: I'm intentionally eliding the plugin setup, GRPC interceptor, etc. since it works as expected on the happy path.
Minimal Reproduction
I don't know of a minimal authorization plugin that I can run so this is a little more vague than I would like. Apologies in advance.
The Temporal environment variables (somewhat redacted):
The unhappy path:
tctl-auth
in our case)tctl wf show
tctl-auth
process is left running in the backgroundExample:
The happy path:
tctl-auth
in our case)tctl wf show -w <valid-workflow-id>
tctl-auth
processes are left running in the backgroundExample:
Environment/Versions
tctl
Version: 1.16.2Additional context
Our authentication plugin is a Go application using cobra for CLI command parsing and boils down to:
The text was updated successfully, but these errors were encountered: