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

Add Docker provider #977

Merged
merged 5 commits into from
May 8, 2019
Merged

Conversation

wainersm
Copy link
Contributor

This set of commits add basic docker provider which is able to manage container and image resources.

On commit 79ad73c for the docker_image resource, it was used the path_relative_to filter to make some parameters relative to the workspace. Same thing could be implemented with some parameters of the docker_container resource, however I will wait the review of this set of commits before I follow up with that.

It was not implemented test cases because I still don't understand how they can be implemented. I appreciate if anyone gives some guidance on it. It could come on a follow up patch as well...

Fixes #957

@adl-bot
Copy link

adl-bot commented Feb 25, 2019

Can one of the admins verify this patch?

@samvarankashyap samvarankashyap modified the milestones: v1.7.3, v1.7.2 Feb 25, 2019
@p3ck p3ck modified the milestones: v1.7.2, v1.7.3 Feb 26, 2019
@p3ck
Copy link
Contributor

p3ck commented Feb 26, 2019

I think this needs block: sections around the docker calls in roles/docker/tasks/provision_docker_* with code added for installing docker dependencies like we do for the other providers.

TASK [docker : Provision Docker image] *****************************************************************
task path: /home/bpeck/Projects/LinchPin/lib/python2.7/site-packages/linchpin/provision/roles/docker/tasks/provision_docker_image.yml:16
fatal: [localhost]: FAILED! => {
    "changed": false, 
    "invocation": {
        "module_args": {
            "api_version": "auto", 
            "archive_path": null, 
            "buildargs": null, 
            "cacert_path": null, 
            "cert_path": null, 
            "container_limits": null, 
            "debug": false, 
            "docker_host": "unix://var/run/docker.sock", 
            "dockerfile": "fedora29", 
            "force": false, 
            "http_timeout": null, 
            "key_path": null, 
            "load_path": null, 
            "name": "custom_fedora29", 
            "nocache": false, 
            "path": "/home/bpeck/Sandbox/contra/linchpin/docs/source/examples/workspaces/docker/dockerfiles", 
            "pull": true, 
            "push": false, 
            "repository": null, 
            "rm": true, 
            "ssl_version": null, 
            "state": "present", 
            "tag": "python", 
            "timeout": 60, 
            "tls": false, 
            "tls_hostname": "localhost", 
            "tls_verify": false, 
            "use_tls": "no"
        }
    }, 
    "msg": "Failed to import docker or docker-py - No module named docker. Try `pip install docker` or `pip install docker-py` (Python 2.6)"
}
	to retry, use: --limit @/home/bpeck/Projects/LinchPin/lib/python2.7/site-packages/linchpin/provision/docker.retry

PLAY RECAP *********************************************************************************************
localhost                  : ok=9    changed=0    unreachable=0    failed=1   

Unsuccessful provision of resource

@wainersm
Copy link
Contributor Author

I think this needs block: sections around the docker calls in roles/docker/tasks/provision_docker_* with code added for installing docker dependencies like we do for the other providers.

I just realized linchpin has a "linchpin setup " command. Btw, opened a PR to improve it #993

Taken provision/roles/libvirt/tasks/provision_libvirt_node.yml as an example, I should:

  1. Enclose the ansible's docker module call in a block/rescue, and the message tells the user to run "linchpin setup docker"
  2. Add a playbook under roles/dependencies/tasks/ for docker installation
  3. Edit roles/dependencies/tasks/main.yml properly

@p3ck , on regarding dependencies installation, that's all I should do?

@p3ck
Copy link
Contributor

p3ck commented Feb 27, 2019

@wainersm sounds correct. I'll re-review when you post here. Thanks!

@adl-bot
Copy link

adl-bot commented Feb 28, 2019

@wainersm
Copy link
Contributor Author

@p3ck Updated the PR, the setup instructions are isolated in a commit.

@p3ck
Copy link
Contributor

p3ck commented Feb 28, 2019

@wainersm Thank you. We are in the middle of releasing 1.7.2 so will look to merge this after that is finished.

@wainersm wainersm force-pushed the docker_provider_v3 branch from 5fae0b4 to e6f6c23 Compare March 11, 2019 17:26
@wainersm
Copy link
Contributor Author

wainersm commented Mar 11, 2019

@p3ck I've just pushed the commit e6f6c23 that introduces tests to the docker provider. I tests passed on my Fedora 19 machine, where I did:

cd config/Dockerfiles
make all
./run_tests.sh $LINCHPIN_SRC fedora29
make DISTROS=fedora28 all
./run_tests.sh $LINCHPIN_SRC fedora28
  • Note: 1) changed run_tests.sh to execute docker provider tests 2) failed to run on centos7, but actually it did not installed linchpin on the container so I think it is not related with my changes.

@wainersm wainersm force-pushed the docker_provider_v3 branch from e6f6c23 to 820a6e8 Compare March 11, 2019 17:56
@wainersm
Copy link
Contributor Author

Rebased the code to latest so that it resolved a conflict in config/Dockerfiles/tests.d/inventory/01_template_inventory file.

@adl-bot
Copy link

adl-bot commented Mar 11, 2019

@adl-bot
Copy link

adl-bot commented Mar 11, 2019

@samvarankashyap samvarankashyap modified the milestones: v1.7.3, v1.7.4 Mar 19, 2019
@wainersm
Copy link
Contributor Author

@samvarankashyap is needed something from my side to move this PR forward?

@14rcole
Copy link
Contributor

14rcole commented Apr 2, 2019

@wainersm can you rebase against develop? Thanks!

@samvarankashyap
Copy link
Contributor

moving it to 1.7.5 since we are waiting on rebase

@samvarankashyap samvarankashyap modified the milestones: v1.7.4, 1.7.5 Apr 18, 2019
@wainersm wainersm force-pushed the docker_provider_v3 branch from 820a6e8 to 8a7c2ac Compare April 23, 2019 21:26
@wainersm
Copy link
Contributor Author

@14rcole @samvarankashyap I've just rebased it to latest.

@14rcole
Copy link
Contributor

14rcole commented Apr 24, 2019

@wainersm looks like you've got some unit test/formatting errors

@samvarankashyap
Copy link
Contributor

@wainersm Please fix the following flake8 errors:

$ flake8 --exclude=\.eggs,tests,docs --ignore=E124,E303,W504 --max-line-length 80 .
./linchpin/provision/filter_plugins/path_relative_to.py:5:1: E302 expected 2 blank lines, found 1
./linchpin/provision/filter_plugins/path_relative_to.py:10:28: E231 missing whitespace after ','
./linchpin/provision/filter_plugins/path_relative_to.py:10:33: E231 missing whitespace after ','
./linchpin/provision/filter_plugins/path_relative_to.py:10:39: E231 missing whitespace after ','
./linchpin/provision/filter_plugins/path_relative_to.py:14:1: E302 expected 2 blank lines, found 1
./linchpin/provision/filter_plugins/path_relative_to.py:17:17: E126 continuation line over-indented for hanging indent
./linchpin/provision/filter_plugins/path_relative_to.py:18:17: E123 closing bracket does not match indentation of opening bracket's line
./linchpin/provision/filter_plugins/path_relative_to.py:19:1: W391 blank line at end of file
./linchpin/InventoryFilters/DockerInventory.py:8:1: E302 expected 2 blank lines, found 1
./linchpin/InventoryFilters/DockerInventory.py:34:1: W391 blank line at end of file
The command "flake8 --exclude=\.eggs,tests,docs --ignore=E124,E303,W504 --max-line-length 80 ." exited with 1.

The docker provider introduced on this change allows one to
provision a docker container.

This implementation is a wrapper around Ansible's docker_container module.

Fixes issue CentOS-PaaS-SIG#957
This filter expect a base_path and path arguments, check if path is absolute
or relative to the OS filesystem then:
1. In either case, return the path as is.
2. Otherwise, return the base_path + path.

Examples:
-> {{ '/path/to/files' | path_relative_to('/path/to/workspace') }}
<- "/path/to/files"

-> {{ 'files' | path_relative_to('/path/to/workspace') }}
<- "/path/to/workspace/files"
This extend the docker provider to allow creation/destroy of
container images. Currently it is a wrapper around the Ansible's
docker_image module, but it does not allow to push or archive
an image.
Added support for installing docker dependencies with
`linchpin setup docker`
Added tests for docker setup and container provisioning.
It was disabled execution of general/01_general and
inventory/01_template_inventory because they required
docker setup correctly in the test container.
@wainersm wainersm force-pushed the docker_provider_v3 branch from 8a7c2ac to 116d869 Compare April 24, 2019 17:06
@wainersm
Copy link
Contributor Author

@samvarankashyap @14rcole ok, now I fixed all checks fail. :)

@samvarankashyap
Copy link
Contributor

@wainersm I see all check pass now, We will try to incorporate docker provider into 1.7.5 release.
Thank you for your contribution.

@wainersm
Copy link
Contributor Author

wainersm commented May 8, 2019

@samvarankashyap hello! any update on this PR?

@14rcole
Copy link
Contributor

14rcole commented May 8, 2019

@wainersm now that 1.7.4 has been released, we can merge this

@14rcole
Copy link
Contributor

14rcole commented May 8, 2019

[merge]

@adl-bot adl-bot merged commit f3f1b1b into CentOS-PaaS-SIG:develop May 8, 2019
@wainersm
Copy link
Contributor Author

wainersm commented May 9, 2019

Thanks @14rcole !

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

Successfully merging this pull request may close these issues.

RFE: add docker provider
5 participants