Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running multiple postStart events is not allowed #1011

Closed
MazArslan opened this issue Jan 3, 2023 · 2 comments · Fixed by #1081
Closed

Running multiple postStart events is not allowed #1011

MazArslan opened this issue Jan 3, 2023 · 2 comments · Fixed by #1081
Milestone

Comments

@MazArslan
Copy link
Contributor

Description

When I try to use multiple post start events, i get an error saying that Error processing devfile: component tools has multiple postStart events attached to it. As per the devfile 2 schema validation, this is a valid syntax, since both, postStart and commands are accepting array of elements.

How To Reproduce

schemaVersion: 2.1.0
metadata:
  name: demo-project
components:
  - name: tools
    container:
      image: quay.io/devfile/universal-developer-image:ubi8-f5ffca8
      memoryRequest: 1Gi
      memoryLimit: 3Gi
      cpuLimit: 1000m
      cpuRequest: 500m
commands:
  - id: second-command
    exec:
      component: tools
      commandLine: "echo second command"
  - id: install
    exec:
      component: tools
      commandLine: "/home/user/.sdkman/candidates/jbang/current/bin/jbang trust add -o --fresh --quiet https://github.com/apache/camel/blob/HEAD/dsl/camel-jbang/camel-jbang-main/dist/CamelJBang.java"
events:
  postStart:
    - install
    - second-command

create 2 commands and use both on a post start

when trying to run use the devfile getting this issue when trying to create workspace
Error processing devfile: component tools has multiple postStart events attached to it

Expected behavior

to apply the both/multiple post start events.

Additional context

@amisevsk
Copy link
Collaborator

amisevsk commented Jan 5, 2023

The reason postStart is a list of strings is to allow running multiple postStart commands in separate containers (e.g. containerA and containerB), and this should be supported by DWO without further changes. For example, the following devfile should have no issue

schemaVersion: 2.1.0
metadata:
  name: demo-project
components:
  - name: tools
    container:
      image: quay.io/devfile/universal-developer-image:ubi8-f5ffca8
  - name: database
    container:
      image: quay.io/devfile/universal-developer-image:ubi8-f5ffca8
commands:
  - id: second-command
    exec:
      component: tools
      commandLine: "echo second command"
  - id: install
    exec:
      component: database
      commandLine: "/home/user/.sdkman/candidates/jbang/current/bin/jbang trust add -o --fresh --quiet https://github.com/apache/camel/blob/HEAD/dsl/camel-jbang/camel-jbang-main/dist/CamelJBang.java"
events:
  postStart:
    - install
    - second-command

I'd love to support multiple poststart events for the same component, but it would be difficult to do -- the underlying mechanism used is Kubernetes lifecycle hooks, which only support a single command per container. To implement such functionality in DWO would require either managing lifecycle hooks ourselves (which DWO is not suited to do) or figuring out a safe way to chain arbitrary commands (which I don't believe is fully possible).

@l0rd
Copy link
Collaborator

l0rd commented Mar 27, 2023

This has become critical after this issue has been addressed.

Downstream issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants