Introduce gl_workspace_reconciled_actual_state file var
MRs:
-
Refactor and cleanup WorkspaceVariable handling (!182365 - merged) (branch:
caw-ws-add-actual-state-workspace-var
) - (branch:
caw-ws-add-actual-state-workspace-var-2
)
Description
Introduce gl_workspace_reconciled_actual_state
internal FILE variable to be sent to kubernetes in the reconciliation response.
This will NOT be handled like a normal WorkspaceVariable
, and will NOT written to the database in ee/lib/remote_development/workspace_operations/create/workspace_variables_builder.rb
.
This is because this needs to be a dynamically-updated value, with the current actual_state
sent on every reconciliation response in the config_to_apply
This issue is in support of Startup scripts for Remote Development workspac... (&15602)
See details in the High level overview of implementation plan section of that epic (item number 4
).
Acceptance criteria
-
FILE variable should be set in running workspace, and updated whenever workspace's actual_state
changes.
Implementation plan
See details in the High level overview of implementation plan section of Startup scripts for Remote Development workspac... (&15602) epic.
Summary
We leverage Kubernetes postStart
hooks to implement the devfile spec postStart
events. This is what Eclipse Che, the reference implementation for the devfile spec, does.
In order to work properly the Kubernetes postStart
hooks must block execution of commands from user-defined devfile postStart
events until the pod is in the Ready
status.
This is necessary so that we ensure all the containers of the pod are fully ready before attempting to run the user's postStart commands.
However, the workspace containers have no access to the pod to obtain this status.
Therefore, we will leverage the existing support to set FILE-based WorkspaceVariable
entries to communicate this information from Rails to the workspace container.
We will introduce a gl_workspace_reconciled_actual_state
internal file variable to be sent to kubernetes, which will contain the current value of the workspace's actual_state
at the time of reconciliation. This will be similar to other internal variables in ee/lib/remote_development/workspace_operations/create/workspace_variables.rb
, except that it won't be a WorkspaceVariable
model, and won't be stored in the database
Then, the kubernetes postStart
hook logic can then inspect the contents of this file, and block (sleep in a loop) running the user's devfile postStart
commands until the value of the file is Running
.