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 a basic, first pass odo push with Docker support #2806

Merged

Conversation

johnmcollier
Copy link
Member

@johnmcollier johnmcollier commented Apr 2, 2020

What type of PR is this?
/kind feature

What does does this PR do / why we need it:
This PR implements a basic, first pass implementation of odo push with local Docker containers when the PushTarget preference is set to Docker. Currently it's limited to just deploying the containers and setting up the shared source volume. This will unblock folks who are assigned issues that are dependent on this functionality (such as #2717, #2580, #2581)

So, what does the PR do in all?

  • Creates a Docker platform adapter for interacting with devfile components in Docker

    • The Docker adapter is used only if experimental is true and PushTarget is set to Docker
  • Creates a Docker component adapter, which does the following

    • Push pulls images and starts containers based on what was specified in the devfile. Each container is labeled with component=<odo-componentName> and alias=<devfile-component-alias> that provide an easy way to group and find the pods associated with an odo component
    • DoesComponentExist returns true if there's at least one container running that's labeled with component=<odo-componentName>
  • Unit tests

  • Integration tests

Which issue(s) this PR fixes:

Fixes #2579

How to test changes / Special notes to the reviewer:

  1. Have Docker installed and running on your system

  2. Build my branch

  3. Set both experimental mode to true and PushTarget to Docker

    • odo preference set experimental true
    • odo preference set pushtarget docker
  4. Create a devfile component

    • odo create openLiberty
  5. odo push

Signed-off-by: John Collier <John.J.Collier@ibm.com>
Signed-off-by: John Collier <John.J.Collier@ibm.com>
Signed-off-by: John Collier <John.J.Collier@ibm.com>
Signed-off-by: John Collier <John.J.Collier@ibm.com>
Signed-off-by: John Collier <John.J.Collier@ibm.com>
Signed-off-by: John Collier <John.J.Collier@ibm.com>
Signed-off-by: John Collier <John.J.Collier@ibm.com>
Signed-off-by: John Collier <John.J.Collier@ibm.com>
@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation label Apr 2, 2020
Signed-off-by: John Collier <John.J.Collier@ibm.com>
@amitkrout
Copy link
Contributor

Integration tests coming in a later commit to this branch. Needed to get this PR up first before experimenting with Travis

👍
@johnmcollier It won't be much complex to run the test on travis. As we have oc cluster up configured to run for each job on travis which uses default running docker instances as a pre requisite. So you just need to write the test scenario, write the make target for it then call it in .travis.yaml.

As part of running the same test on 4.* is concerned there we need to figure out how to do it (Possibly we need to configure docker instances in the test container). I would suggest create a separate issue for running the same test against 4.* cluster and assign it to @prietyc123.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Apr 5, 2020
Signed-off-by: John Collier <John.J.Collier@ibm.com>
Signed-off-by: John Collier <John.J.Collier@ibm.com>
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Apr 6, 2020
@johnmcollier
Copy link
Member Author

Updated the PR with integration tests 😃

For now they're just running in Travis, I'll open an issue later today to track running them elsewhere.

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

codecov bot commented Apr 6, 2020

Codecov Report

Merging #2806 into master will increase coverage by 0.80%.
The diff coverage is 73.70%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2806      +/-   ##
==========================================
+ Coverage   43.06%   43.87%   +0.80%     
==========================================
  Files          97      102       +5     
  Lines        8917     9147     +230     
==========================================
+ Hits         3840     4013     +173     
- Misses       4713     4761      +48     
- Partials      364      373       +9     
Impacted Files Coverage Δ
pkg/devfile/adapters/helper.go 10.71% <0.00%> (-5.96%) ⬇️
pkg/lclient/client.go 0.00% <ø> (ø)
pkg/lclient/containers.go 58.97% <39.13%> (-29.92%) ⬇️
pkg/lclient/images.go 60.00% <60.00%> (ø)
pkg/devfile/adapters/docker/component/utils.go 65.51% <65.51%> (ø)
pkg/devfile/adapters/docker/component/adapter.go 70.58% <70.58%> (ø)
pkg/devfile/adapters/docker/utils/utils.go 100.00% <100.00%> (ø)
pkg/lclient/fakeclient.go 66.30% <100.00%> (+23.68%) ⬆️
pkg/lclient/generators.go 100.00% <100.00%> (ø)
pkg/lclient/storage.go 100.00% <100.00%> (ø)
... and 6 more

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 11e04b6...c3020b8. Read the comment docs.

Copy link
Contributor

@maysunfaisal maysunfaisal left a comment

Choose a reason for hiding this comment

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

Thx for this PR, impressed by the quick turnaround considering all the logic that is in here!

Review is mostly just re-arranging code and functions to be consistent with the devfile kubernetes package, since they seem out of place looking at the two packages simultaneously and few nits here and there which can go either way depending on how you prefer it.

pkg/devfile/adapters/helper.go Outdated Show resolved Hide resolved
pkg/lclient/containers.go Outdated Show resolved Hide resolved
pkg/devfile/adapters/docker/component/adapter.go Outdated Show resolved Hide resolved
pkg/devfile/adapters/docker/component/adapter.go Outdated Show resolved Hide resolved
pkg/lclient/containers.go Show resolved Hide resolved
pkg/devfile/adapters/docker/component/adapter.go Outdated Show resolved Hide resolved
pkg/devfile/adapters/docker/component/adapter.go Outdated Show resolved Hide resolved
pkg/devfile/adapters/docker/component/adapter.go Outdated Show resolved Hide resolved
pkg/devfile/adapters/docker/component/adapter.go Outdated Show resolved Hide resolved
pkg/devfile/adapters/docker/component/adapter.go Outdated Show resolved Hide resolved
Signed-off-by: John Collier <John.J.Collier@ibm.com>
Signed-off-by: John Collier <John.J.Collier@ibm.com>
Signed-off-by: John Collier <John.J.Collier@ibm.com>
Signed-off-by: John Collier <John.J.Collier@ibm.com>
Copy link
Contributor

@maysunfaisal maysunfaisal left a comment

Choose a reason for hiding this comment

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

Minor changes and questions

Looks good and works well, I can add lgtm after small cleanups

pkg/lclient/storage.go Show resolved Hide resolved
// Start the container
err = a.startContainer(componentName, projectVolumeName, comp)
if err != nil {
return errors.Wrapf(err, "Unable to start container for devfile component %s", *comp.Alias)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about s.End(false)

Copy link
Member Author

Choose a reason for hiding this comment

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

See my reply to your other comment.

tests/integration/docker/cmd_docker_devfile_push_test.go Outdated Show resolved Hide resolved
}

// NewDockerRunner initializes new DockerRunner
func NewDockerRunner(ocPath string) DockerRunner {
Copy link
Contributor

Choose a reason for hiding this comment

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

ocPath to dockerPath

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@@ -0,0 +1,81 @@
package docker
Copy link
Contributor

Choose a reason for hiding this comment

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

how do you feel about all devfile tests being under the devfile dir? and then separated out to tests/integration/devfile/docker and tests/integration/devfile/kube

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, fixed. I moved the docker tests to tests/integration/devfile/docker, we can move the kube tests later.

tests/integration/docker/cmd_docker_devfile_push_test.go Outdated Show resolved Hide resolved
Signed-off-by: John Collier <John.J.Collier@ibm.com>
@maysunfaisal
Copy link
Contributor

changes look good
/lgtm

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. Required by Prow. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. labels Apr 10, 2020
Signed-off-by: John Collier <John.J.Collier@ibm.com>
Signed-off-by: John Collier <John.J.Collier@ibm.com>
@openshift-ci-robot openshift-ci-robot removed lgtm Indicates that a PR is ready to be merged. Required by Prow. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. labels Apr 15, 2020
@johnmcollier
Copy link
Member Author

Had to fix a merge conflict

@maysunfaisal
Copy link
Contributor

adding back lgtm after rebase
/lgtm

@maysunfaisal
Copy link
Contributor

/retest

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

kadel commented Apr 15, 2020

/retest
/approve

@openshift-ci-robot
Copy link
Collaborator

@kadel: The /retest command does not accept any targets.
The following commands are available to trigger jobs:

  • /test unit
  • /test v4.2-integration-e2e-benchmark
  • /test v4.3-integration-e2e-benchmark
  • /test v4.4-integration-e2e-benchmark

Use /test all to run all jobs.

In response to this:

/retest
/approve

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@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 Apr 15, 2020
@openshift-bot
Copy link

/retest

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

1 similar comment
@openshift-bot
Copy link

/retest

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

@johnmcollier
Copy link
Member Author

/retest

@openshift-merge-robot openshift-merge-robot merged commit 22a6364 into redhat-developer:master Apr 16, 2020
mik-dass pushed a commit to mik-dass/odo that referenced this pull request Apr 16, 2020
…developer#2806)

* Implement docker adapter

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

* Docker component support

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

* Implement odo push for Docker

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

* Create helper file for integration tests

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

* Fix build and test issues

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

* Don't require kube client for odo create

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

* Fix storage tests

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

* Address gosec messages

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

* Finish docker integration tests

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

* Fix borked git rebase

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

* Address review comments

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

* Fix merge conflict issues

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

* Fix more merge conflict issues

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

* Fix more merge conflicts in tests

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

* Address rev

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

* Don't require kube context

Signed-off-by: John Collier <John.J.Collier@ibm.com>
@kadel
Copy link
Member

kadel commented Apr 21, 2020

As part of running the same test on 4.* is concerned there we need to figure out how to do it (Possibly we need to configure docker instances in the test container). I would suggest create a separate issue for running the same test against 4.* cluster and assign it to @prietyc123.

Why we would want to run this against clusters. No cluster is used in this case, it is just using Docker daemon

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/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation 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.

Odo push should deploy local Docker containers when pushtarget is set to Docker
8 participants