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

Validate exec subcommands in a composite #3658

Conversation

johnmcollier
Copy link
Member

@johnmcollier johnmcollier commented Jul 29, 2020

What type of PR is this?
/kind bug

What does does this PR do / why we need it:
This PR fixes an issue with composite commands where exec subcommands are not validated (such as exec commands that reference an invalid component). With this PR, when we recursively validate the command-tree in a composite command, we now make sure to validate any exec commands.

Composite subcommands were already being validated.

Which issue(s) this PR fixes:

Fixes #3656

PR acceptance criteria:

  • Unit test

  • Integration test

How to test changes / Special notes to the reviewer:

  1. Run integreation and unit tests
  2. Test with sample devfile:
schemaVersion: 2.0.0
metadata:
  name: nodejs
  version: 1.0.0
projects:
  - name: nodejs-starter
    git:
      location: "https://github.com/odo-devfiles/nodejs-ex.git"
components:
  - container:
      name: runtime
      image: registry.access.redhat.com/ubi8/nodejs-12:1-36
      memoryLimit: 1024Mi
      mountSources: true
      endpoints:
        - name: http-3000
          targetPort: 3000
commands:
  - exec:
      id: install
      component: runtime
      commandLine: npm install
      workingDir: ${CHE_PROJECTS_ROOT}/nodejs-starter
      group:
        kind: build
        isDefault: false
  - exec:
      id: mkdir
      component: fakecomponent
      commandLine: mkdir /projects/testfolder
      workingDir: ${CHE_PROJECTS_ROOT}/nodejs-starter
      group:
        kind: build
        isDefault: false
  - exec:
      id: run
      component: runtime
      commandLine: npm start
      workingDir: ${CHE_PROJECTS_ROOT}/nodejs-starter
      group:
        kind: run
        isDefault: true
  - composite:
         id: buildAndMkdir
         label: Build and Mkdir
         commands:
           - mkdir
           - install
         parallel: false
         group: 
            kind: build
            isDefault: true

This devfile has a composite command whose exec subcommand points to a non-existent component. Odo will spit out the following error when you try to push: the composite command "buildandmkdir" references an invalid command "mkdir": the command does not map to a supported component

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jul 29, 2020
@codecov
Copy link

codecov bot commented Jul 30, 2020

Codecov Report

Merging #3658 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3658      +/-   ##
==========================================
+ Coverage   45.49%   45.50%   +0.01%     
==========================================
  Files         122      122              
  Lines       12286    12290       +4     
==========================================
+ Hits         5589     5593       +4     
  Misses       6146     6146              
  Partials      551      551              
Impacted Files Coverage Δ
pkg/devfile/adapters/common/command.go 96.44% <100.00%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e6801f9...a6f8fd3. Read the comment docs.

Copy link
Contributor

@mik-dass mik-dass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me 👍
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jul 30, 2020
@kadel
Copy link
Member

kadel commented Jul 30, 2020

/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kadel

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Jul 30, 2020
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

17 similar comments
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

5 similar comments
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@kadel
Copy link
Member

kadel commented Aug 3, 2020

/retest

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

15 similar comments
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit db5a56a into redhat-developer:master Aug 4, 2020
cdrage pushed a commit to cdrage/odo that referenced this pull request Aug 4, 2020
* Validate exec subcommands in composite

* Add integration test
cdrage added a commit that referenced this pull request Aug 4, 2020
* Adds documentation on Devfile file reference (#3487)

**What type of PR is this?**
> Uncomment only one ` /kind` line, and delete the rest.
> For example, `> /kind bug` would simply become: `/kind bug`

> Documentation changes: Please include [skip ci] in your commit message as well
/kind documentation
[skip ci]

**What does does this PR do / why we need it**:

This PR adds documentation regarding each section of Devfile and what we
support / do not support

**Which issue(s) this PR fixes**:

N/A

**How to test changes / Special notes to the reviewer**:

N/A

Signed-off-by: Charlie Drage <charlie@charliedrage.com>

* Update file reference documentation (#3675)

**What type of PR is this?**
> Uncomment only one ` /kind` line, and delete the rest.
> For example, `> /kind bug` would simply become: `/kind bug`

/kind documentation
[skip ci]

**What does does this PR do / why we need it**:

Updates the file reference documentation to not have the introductory
section and move unsupported features to the bottom.

**Which issue(s) this PR fixes**:

N/A

**PR acceptance criteria**:

N/A

**How to test changes / Special notes to the reviewer**:

N/A

Signed-off-by: Charlie Drage <charlie@charliedrage.com>

* make odo delete work on s2i components in experimental mode (#3649)

* Fixes GetRunningPodNameByComponent for the CLI runners (#3666)

* increase ResponseHeaderTimeout (#3674)

* Make the file sync destination more consistent (#3662)

* Make the file sync destination more consistent

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Update tests to use PROJECTS_ROOT

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Fix workdir in tests

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Remove more references to nodejs-starter

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Update more sample devfiles

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* make odo catalog list components work outside of experimental mode (#3669)

* make odo catalog list components work outside of experimental mode

* moved the logic to cli

* Ignore error while checking for imagestream support

* rearranged the catalog list

* Validate exec subcommands in a composite (#3658)

* Validate exec subcommands in composite

* Add integration test

* added --s2i flag for `odo create` command

* corrected error messages

* Corrected flag description and validation

* added --s2i flag for `odo create` command

* Make Devfile the default deployment mechanism for odo

**What type of PR is this?**
> Uncomment only one ` /kind` line, and delete the rest.
> For example, `> /kind bug` would simply become: `/kind bug`

/kind feature

**What does does this PR do / why we need it**:

Makes Devfile the default deployment mechanism, removing S2I in favour
of Devfile deployment.

**Which issue(s) this PR fixes**:

Closes #3550

**How to test changes / Special notes to the reviewer**:

Run:

```sh
odo preference set experimental false
odo create --starter nodejs
odo push
```

Co-authored-by: Girish Ramnani <girishramnani95@gmail.com>
Co-authored-by: Mrinal Das <mrinald7@gmail.com>
Co-authored-by: Tomas Kral <tkral@redhat.com>
Co-authored-by: John Collier <John.J.Collier@ibm.com>
Co-authored-by: Devang Gaur <devang.gaur.7@gmail.com>
cdrage pushed a commit to cdrage/odo that referenced this pull request Aug 4, 2020
* Validate exec subcommands in composite

* Add integration test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate comp cmd's child cmd to a valid container component
6 participants