redhat-developer / web-terminal-operator

OpenShift Console Web Terminal
MIT License
41 stars 15 forks source link

Decouple web terminal idle timeout from DevWorkspace idle timeout #114

Closed amisevsk closed 2 years ago

amisevsk commented 2 years ago

What does this PR do?

Set timeout for web terminals through an environment variable in the web-terminal-exec plugin rather than through the automatically provisioned DEVWORKSPACE_IDLE_TIMEOUT environment variable. This allows the timeout for individual terminals to be changed without overriding the timeout for all DevWorkspaces

The main reason to update the idle timeout currently is that the bash history is erased when a Web Terminal is idled. By setting a longer duration, a session could continue for e.g. a full work day.

What issues does this PR fix or reference?

We've had a number of requests for how to increase the web terminal timeout, which normally requires editing the DevWorkspace Operator config or the web-terminal-exec. With these changes, it's easy to override the timeout for individual web terminals in a persistent way.

Is it tested? How?

Start a web terminal with these changes and verify that the updated variable is used for idle timeout. To shorten it for the current web terminal, paste and execute the command

kubectl get dw -o json \
  -n $(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace) \
  $DEVWORKSPACE_NAME \
  | jq '.spec.template.components[1].plugin.components = [{
      "name": "web-terminal-exec",
      "container": {
        "env": [{
          "name": "WEB_TERMINAL_IDLE_TIMEOUT",
          "value": "15s",
        }]
      },
    }]' \
  | kubectl apply -f -