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

Container contributions are not merged when there is a variable validation warning #1302

Open
dkwon17 opened this issue Aug 9, 2024 · 0 comments

Comments

@dkwon17
Copy link
Collaborator

dkwon17 commented Aug 9, 2024

Description

When creating a workspace with this DevWorkspace:

DevWorkspace CR
kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2
metadata:
  name: code-latest
spec:
  started: true
  template:
    projects:
      - name: web-nodejs-sample
        git:
          remotes:
            origin: "https://github.com/che-samples/web-nodejs-sample.git"
    components:
      - name: dev
        container:
          image: quay.io/devfile/universal-developer-image:latest
          memoryLimit: 512Mi
          memoryRequest: 256Mi
          cpuRequest: 1000m
    commands:
      - id: 
  template:
    projects:
      - name: web-nodejs-sample
        git:
          remotes:
            origin: "https://github.com/che-samples/web-nodejs-sample.git"
    components:
      - name: dev
        container:
          image: quay.io/devfile/universal-developer-image:latest
          memoryLimit: 512Mi
          memoryRequest: 256Mi
          cpuRequest: 1000m
    commands:
      - id: say-hello
        exec:
          component: dev
          commandLine: echo "Hello {{test}} $(pwd)"
          workingDir: ${PROJECT_SOURCE}/app
  contributions:
    - name: che-code
      uri: https://eclipse-che.github.io/che-plugin-registry/main/v3/plugins/che-incubator/che-code/latest/devfile.yaml
      components:
        - name: che-code-runtime-description
          container:
            env:
              - name: CODE_HOST
                value: 0.0.0.0

the workspace starts and container contributions do not happen.

In the example above, there is a undeclared variable {{test}} in the say-hello command.

See usage of variables in devfile spec

How To Reproduce

  1. Create the DevWorkspace reference above
  2. When the workspace pod starts, verify that the che-code-runtime-description exists as it's own container in the pod:
    image

Expected behavior

Ideally, workspace start should fail with a descriptive error message in this case.

Additional context

It's happening if the global variable validation fails here:

warnings := variables.ValidateAndReplaceGlobalVariable(resolvedDW)
if len(warnings.Commands) > 0 || len(warnings.Components) > 0 || len(warnings.Projects) > 0 || len(warnings.StarterProjects) > 0 {
return resolvedDW, &warnings, nil
}

the function exits early without doing the container contributions and the workspace starts up without notifying the user.

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

No branches or pull requests

1 participant