Add support for user-defined postStart commands
Issue: Add support for devfile postStart event in Work... (#505988 - closed)
What does this MR do and why?
This MR aims to add support for user defined postStart events in the Devfile
It contains the following changes:
- Parse postStart events from the devfile and adds them to the desired configuration for k8s
- Add validation for commands and events
- Supported command types are [
exec
,apply
] - Checks presence of
component
which is a required field for bothexec
andapply
-
exec
commands supported options [component
,commandLine
,label
,hotReloadCapable
] -
hotReloadCapable
supported value isfalse
which is the default value -
postStart
events only supportexec
commands. Commands of typeapply
should be inpreStart
event
- Supported command types are [
- Adds tests for postStart events
TODOs (followup discussion):
- Support
composite
command type https://devfile.io/docs/2.3.0/adding-a-composite-command - Support all command options like [environment, workingDir, group]
- Should we support
apply
command type inpostStart
events?
References
- Devfile: Adding event bindings
- Devfile schema - Version 2.3.0 - exec commands
- add_poststart_commands in main_component_updater.rb
- Add support for devfile postStart event in Work... (#505988 - closed)
Screenshots or screen recordings
This MR does not contain any UI changes
Devfile (command specified) | Workspace (command executed) |
---|---|
![]() |
![]() |
How to set up and validate locally
- Setup workspaces locally following this guide
- Checkout this branch and add a devfile to any of your projects.
- And add an exec command to the devfile. Example here: https://devfile.io/docs/2.3.0/adding-an-exec-command
- Currently only
component
,commandLine
,label
andhotReloadCapable: false
are supported options - Check that the correct validation errors are returned for unsupported options - Add your command as a postStart event in the devfile. Example here: https://devfile.io/docs/2.3.0/adding-event-bindings
- Then go to
http://gdk.test:3000/-/remote_development/workspaces
and create a new workspace for that project. - Open the workspace, check the log file for the script at
../workspace-logs/poststart-stdout.log
. It should have your postStart command listed at the end once the workspace is in aRunning
state and this log line has been printed:Workspace state is now 'Running', continuing postStart hook execution
- Confirm that whatever your postStart command was, it ran successfully inside the workspace.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
-
postStart
entries in devfile are executed when the container to which they are bound is successfully started. -
Either support all valid devfile schema postStart options, e.g. workingDir
as per https://devfile.io/docs/2.3.0/adding-event-bindings, or else document they are not supported, and add validation to prevent their usage. See related comment. -
User-defined postStart commands should have a validation steps added to the steps of the ".../workspace_operations/create" ROP chain. This should attempt to validate, as much as possible, that all user-defined postStart commands are valid bash commands -
Middle-of-testing-pyramid integration tests are added/updated at ee/spec/lib/remote_development/workspace_operations/reconcile/main_integration_spec.rb
-
Update the fixture devfile that contains all of the possible devfile entries
Edited by Daniyal Arshad