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

Implement apply of container component on preStart events #183

Closed
sleshchenko opened this issue Oct 22, 2020 · 0 comments · Fixed by #188
Closed

Implement apply of container component on preStart events #183

sleshchenko opened this issue Oct 22, 2020 · 0 comments · Fixed by #188

Comments

@sleshchenko
Copy link
Member

sleshchenko commented Oct 22, 2020

Is your task related to a problem? Please describe.

To support the new plugins model, it's needed to implement apply of container component on preStart events.
Then we'll be able to describe plugins like the following (it's adapted samples from https://github.com/devfile/api/tree/master/samples):

Base vsx plugin template
schemaVersion: 2.0.0
metadata:
  publisher: redhat
  name: vsx-template
  type: template
  parameters:
    VSX_LIST # ????
components:
  - name: vsx-installer
    container:
      image: vsx-installer # technically it's adapted artifacts plugin broker which is not in place yet
      volumeMounts:
        - name: vsx
          path: "/vsx"
      env:
        - name: VSX_LIST
          value: ""
    - name: theia-remote-injector
      container: 
       image: "quay.io/eclipse/che-theia-endpoint-runtime-binary:7.20.0"
      volumesMounts:
      - mountPath: "/remote-endpoint"
        name: remote-endpoint
      env:
        - name: PLUGIN_REMOTE_ENDPOINT_EXECUTABLE
          value: /remote-endpoint/plugin-remote-endpoint
        - name: REMOTE_ENDPOINT_VOLUME_NAME
          value: remote-endpoint
  - name: remote-endpoint
    volume:
      emptyDir: {} ? №2
commands:
 - id: copyVsx
   apply:
     component: vsx-installer
 - id: injectRemoteILauncher
   apply:
     component: theia-remote-injector
events:
  preStart:
    - copyVsx
    - injectRemoteILauncher

? №1 We don't want to get copies of vsxInstaller and injectRemoteILauncher but the model does not allow to define merging the same components. So, maybe it should be implementation-specific for plugin component - if a different component brings the component with the same name - we try to merge them. Everything except VSX_LIST should be the same.
It may be a bit simpler in terms on interface declaration if we define different env vars in different plugins, like VSX_JAVA_8, VSX_JAVA_DEBUG, ... Otherwise we should hardcode that only VSX_LIST should be merged with appending.

? №2 empty dir volumes are not implemented yet devfile/api#189

Then plugin definition:
schemaVersion: 2.0.0
metadata:
  publisher: redhat
  name: java8
  version: latest
  displayName: Language Support for Java 8
  title: Language Support for Java(TM) by ...
  description: Java Linting, Intellisense ...
  icon: https://.../logo-eclipseche.svg
  repository: https://github.../vscode-java
  category: Language
  firstPublicationDate: "2020-02-20"
  pluginType: che-theia-vsx
parent:
  id: redhat/theia-vsx-template/latest
  components:
    - name: vsx-installer
      container:
        env:
          - name: VSX_LIST
            value: java-dbg.vsix,java.vsix
components:
  - name: vscode-java
    container:
      image: ...che-sidecar-java
      memoryLimit: "1500Mi"
      volumeMounts:
        - path: "/home/theia/.m2"
          name: m2
  - name: m2
    volume: {}    

? №3 # plugin sidercar has entrypoint with env var stub that should be injected from remote injector. See https://github.com/che-dockerfiles/che-sidecar-java/blob/master/Dockerfile#L32
Currently che-plugin-broker encapsulates this logic and apply configuration if the plugin is theia or vscode: https://github.com/eclipse/che-plugin-broker/blob/40cdcfb0e54ef1bf170690045802cc6710c33dfc/brokers/metadata/broker.go#L134
In Devfile 2.0 there is an issue to provide env var to all containers devfile/api#149
But what with remoteInjector emptyDir volumes? Should we contribute it to every container as well? Or maybe producing duplicates but more consistent - plugin container should define remote-endpoint volumeMount.

Then Devfile is just
schemaVersion: 2.0.0
metadata:
  name: spring-boot-http-booster
  type: workspace
projects:
  - name: spring-boot-http-booster
    git:
      remotes:
        origin: https://github.com/snowdrop/spring-boot-http-booster
      checkoutFrom:
        revision: master
components:
 # Should we explicitly define theia as plugin? Probably yes or we should analyze resolved plugin configuration for some indicator if it's editor or not - before providing the default one.
 - name: java-support
    plugin:
      id: redhat/java8/latest
      components:
        - name: vscode-java            
          container:
            memoryLimit: 2Gi
        - name: m2
          volume:
            size: 2G
  - name: maven-tooling
    container:
      image: registry.redhat.io/codeready-workspaces/stacks-java-rhel8:2.1
      mountSources: true
      memoryLimit: 768Mi
      env:
        - name: JAVA_OPTS
          value: >-
            -XX:MaxRAMPercentage=50.0 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10
            -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4
            -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true
            -Xms20m -Djava.security.egd=file:/dev/./urandom -Duser.home=/home/jboss
        - name: MAVEN_OPTS
          value: $(JAVA_OPTS)
      endpoints:
        - name: 8080-tcp
          targetPort: 8080
          exposure: public
      volumeMounts:
        - name: m2
          path: /home/jboss/.m2
commands:
  - id: build 
    exec:
      component: maven
      commandLine: mvn -Duser.home=${HOME} -DskipTests clean install
      workingDir: '${PROJECTS_ROOT}/spring-boot-http-booster'
      env:
        - name: MAVEN_OPTS
          value: "-Xmx200m"
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.

1 participant