Skip to content

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
    1. Supported command types are [exec, apply]
    2. Checks presence of component which is a required field for both exec and apply
    3. exec commands supported options [component, commandLine, label, hotReloadCapable]
    4. hotReloadCapable supported value is false which is the default value
    5. postStart events only support exec commands. Commands of type apply should be in preStart event
  • Adds tests for postStart events

TODOs (followup discussion):

References

Screenshots or screen recordings

This MR does not contain any UI changes

Devfile (command specified) Workspace (command executed)
Screenshot_2025-06-10_at_4.28.09_PM Screenshot_2025-06-10_at_4.37.09_PM

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 and hotReloadCapable: 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 a Running 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

Merge request reports

Loading