From cede7f21b8925fae01b653bf80d9f414805fdae3 Mon Sep 17 00:00:00 2001 From: ksatchit Date: Mon, 9 Oct 2017 09:56:32 +0530 Subject: [PATCH] Placeholder for roles & playbooks to address OpenEBS issue #463 ---------------------------------------------------------------------------------------- 1. Why is this change necessary? - There is a need to reduce the time taken for the integration test suite execution that is triggered by jenkins. This should be approached in different ways, one way being - loading pre-pulled test images just before tests, so as to avoid pulling a test image freshly during the suite - This commit addresses the above by introducing the following : a) Ansible role and playbook to pull test images specified by a list b) Ansible role and playbook to load this into test k8s nodes (vagrantVM /baremetal) c) Updates to ci.yml to include load step d) Updates to global var specification file all.yml to hold some test labels 2. How does this change address the issue? - Expected to reduce test time by having the image tar file ready - The load step, where the images are loaded into the test nodes via docker load command takes time on the vagrant VMs. Need to identify machines w/ better resource OR a more optimal load technique. Sometimes , docker load can be a bursty Write spike on the VM storage which can take up system resources making the process slow. One approach is to have multiple load operations than one single large load. This will also help with versioning/maintenance of test images. However, the current changes will first have to be tested to identify the efficacy before moving on to enhancements. This is yet to be done due to certain issue on the local jenkins setup. 3. What side effects does this change have? - None on the product itself. This is test code --- ansible/ci.yml | 27 ++--- ansible/inventory/group_vars/all.yml | 102 ++++++++++++++++-- ansible/load-images.yml | 15 +++ .../roles/load-test-images/defaults/main.yml | 6 ++ ansible/roles/load-test-images/tasks/main.yml | 28 +++++ .../roles/setup-test-images/defaults/main.yml | 28 +++++ .../roles/setup-test-images/tasks/main.yml | 68 ++++++++++++ ansible/setup-images.yml | 7 ++ 8 files changed, 252 insertions(+), 29 deletions(-) create mode 100644 ansible/load-images.yml create mode 100644 ansible/roles/load-test-images/defaults/main.yml create mode 100644 ansible/roles/load-test-images/tasks/main.yml create mode 100644 ansible/roles/setup-test-images/defaults/main.yml create mode 100644 ansible/roles/setup-test-images/tasks/main.yml create mode 100644 ansible/setup-images.yml diff --git a/ansible/ci.yml b/ansible/ci.yml index e7382408..d3e9f957 100644 --- a/ansible/ci.yml +++ b/ansible/ci.yml @@ -1,26 +1,17 @@ --- -- hosts: localhost +- include: pre-requisites.yml - roles: - - inventory - -- hosts: openebs-mayamaster +- include: setup-kubernetes.yml - roles: - - master - - {role: vagrant, when: is_vagrant_vm | bool} +- include: setup-openebs.yml -- hosts: openebs-mayahosts +- include: load-images.yml - roles: - - hosts - - {role: vagrant, when: is_vagrant_vm | bool} +- include: run-dedicated-tests.yml + when: deployment_mode == "dedicated" -- hosts: localhost +- include: run-hyperconverged-tests.yml + when: deployment_mode == "hyperconverged" - roles: - - {role: localhost, when: run_demo | bool} - - {role: volume, when: run_demo | bool} - - {role: fio, when: run_demo | bool} - - {role: cleanup, when: run_demo | bool} + diff --git a/ansible/inventory/group_vars/all.yml b/ansible/inventory/group_vars/all.yml index e303b9a5..f4bae039 100644 --- a/ansible/inventory/group_vars/all.yml +++ b/ansible/inventory/group_vars/all.yml @@ -1,15 +1,40 @@ --- -#Option to run the sample demo of OpenEBS -#Accepted Entries(true, false): default:true -run_demo: true +######################################### +# Kubernetes Deployment Specification # +######################################### -#Option specifically for vagrant VMs. -#Accepted Entries(true, false): default:false +#Kubernetes Version to be used for deployment +#Accepted Entries (Valid Kubernetes Version): default:1.6.3 +#Accepted Entries (Valid Weave Version): default:1.9.4 + +k8s_version: 1.7.5 +k8s_version: 2.0.4 -is_vagrant_vm: false - -#User-defined size for the volume that openebs creates: +#list of kubernetes versions released. +#do not tamper the list unless you know +#what you are doing... + +k8s_version_list: + - 1.6.2 + - 1.6.3 + - 1.6.4 + - 1.6.5 + - 1.6.6 + - 1.7.0 + - 1.7.2 + - 1.7.4 + - 1.7.5 + +weave_version_list: + - 1.9.4 + - 2.0.4 + +######################################### +# OpenEBS Deployment Specifications # +######################################### + +#User-defined size for the volume that openebs creates #Accepted Entries(Valid Volume Sizes): default:5G openebs_vol_size: 5G @@ -17,9 +42,64 @@ openebs_vol_size: 5G #Available CIDR for allocating IP Addresses for containers #Accepted Entries (Valid CIDR): default:172.28.128.1/24 -cn_network_cidr: 172.28.128.1/24 +cn_network_cidr: 20.10.49.110/25 -#Network interface for CIDR. +#Network interface for CIDR #Accepted Entries (Valid Network Interface): default:enp0s8 -cn_interface: enp0s8 +cn_interface: ens160 + +#Mode of openEBS deployment +#Accepted Entries (dedicated, hyperconverged): default:dedicated + +deployment_mode: hyperconverged + +#Option specifically for vagrant VMs +#Accepted Entries(true, false): default:false + +is_vagrant_vm: true + +######################################### +# Ansible Runtime Specifications # +######################################### + +#Option to run the sample demo of OpenEBS +#Accepted Entries(true, false): default:true + +run_demo: true + +#Option to setup Ansible Runtime Analysis playbook recorder +#Accepted Entries(true, false): default:true + +ara_setup: true + +#Option to enable slack notifications to specified channel +#Accepted Entries(true, false): default:true + +slack_notify: true + +######################################### +# OpenEBS Test Specifications # +######################################### + +#Option to run cleanup functions in tests +#Accepted Entries(true, false): default:true + +clean: true + +#Name of tarfile containing test images + +tarfile: test_images.tar + +######################################### +# OpenEBS CI Specifications # +######################################### + +#Option to select type of CI build +#Accepted Entries(quick, normal): default:normal +#quick build uses preconfigured VMs, +#normal builds upon vanilla VMs + +build_type: normal + + diff --git a/ansible/load-images.yml b/ansible/load-images.yml new file mode 100644 index 00000000..4cc2ee6d --- /dev/null +++ b/ansible/load-images.yml @@ -0,0 +1,15 @@ +--- +- hosts: kubernetes-kubeminions + + tasks: + - name: Check for presence of tarfile + stat: + path: "{{ playbook_dir }}/roles/load-test-images/files/{{ tarfile }}" + register: tar + delegate_to: 127.0.0.1 + + - name: Execute load-test-images role if tarfile exists + include_role: + name: load-test-images + when: tar.stat.exists is defined and tar.stat.exists + diff --git a/ansible/roles/load-test-images/defaults/main.yml b/ansible/roles/load-test-images/defaults/main.yml new file mode 100644 index 00000000..00d62d2d --- /dev/null +++ b/ansible/roles/load-test-images/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +tarfile: test_images.tar + +# Applies to non-vagrant VMs/baremetal +tarfile_path: "{{ ansible_env.HOME}}" diff --git a/ansible/roles/load-test-images/tasks/main.yml b/ansible/roles/load-test-images/tasks/main.yml new file mode 100644 index 00000000..d1690e4f --- /dev/null +++ b/ansible/roles/load-test-images/tasks/main.yml @@ -0,0 +1,28 @@ +--- +- block: + + - name: Load test images from Archive + command: docker load --input "{{ tarfile }}" + args: + chdir: "/vagrant/roles/load-test-images/files" + become: true + + when: is_vagrant_vm + +- block: + + - name: Copy test image tarfile to kubernetes hosts + copy: + src: "{{ tarfile }}" + dest: "{{ tarfile_path }}" + become: true + when: is_vagrant_vm + + - name: Load test images from Archive + command: docker load --input "{{ tarfile }}" + args: + chdir: "{{ tarfile_path }}" + become: true + + when: not is_vagrant_vm + diff --git a/ansible/roles/setup-test-images/defaults/main.yml b/ansible/roles/setup-test-images/defaults/main.yml new file mode 100644 index 00000000..001fc210 --- /dev/null +++ b/ansible/roles/setup-test-images/defaults/main.yml @@ -0,0 +1,28 @@ +--- +deb_local_packages: + - docker.io + +pip_local_packages: + - 'docker-py==1.9.0' + +test_images: + + # I/O-tool-specific images + + #- openebs/tests-fio + #- openebs/tests-vdbench + + # App-specific images + + - percona + - satyamz/docker-jupyter:v0.4 + - crunchydata/crunchy-postgres:centos7-9.6-1.4.0 + #- openebs/tests-mysql-master + #- openebs/tests-mysql-slave + + # App-load-generator images + + - openebs/tests-mysql-client + #- openebs/tests-tpcc-client + +tarfile: test_images.tar diff --git a/ansible/roles/setup-test-images/tasks/main.yml b/ansible/roles/setup-test-images/tasks/main.yml new file mode 100644 index 00000000..9ab2bc49 --- /dev/null +++ b/ansible/roles/setup-test-images/tasks/main.yml @@ -0,0 +1,68 @@ +--- +- name: Install APT Packages + apt: + name: "{{item}}" + state: present + with_items: "{{deb_local_packages}}" + become: true + delegate_to: 127.0.0.1 + +- name: Install PIP Packages + pip: + name: "{{ item }}" + state: present + with_items: "{{ pip_local_packages }}" + delegate_to: 127.0.0.1 + become: true + +- name: Fetch test images from dockerhub + docker_image: + name: "{{item}}" + state: present + pull: true + force: yes + register: result + until: "'Pulled image' and item in result.actions[0]" + delay: 60 + retries: 3 + with_items: "{{ test_images }}" + become: true + +- name: Print test image names + shell: printf "{{ item }}\n" >> imagelist.tmp + with_items: "{{ test_images }}" + +- name: Create files directory in load-test-images role + file: + path: "{{ playbook_dir }}/roles/load-test-images/files" + state: directory + mode: 0755 + +- name: TAR the test images + shell: docker save $(cat imagelist.tmp) -o {{playbook_dir}}/roles/load-test-images/files/{{ tarfile }} + become: true + +- name: Remove the .tmp file created to hold image list + file: path="{{playbook_dir}}/imagelist.tmp" state=absent + +- name: Get current user details + command: whoami + register: user + +- name: Change permissions of tarfile + file: + path: "{{playbook_dir}}/roles/load-test-images/files" + owner: "{{ user.stdout }}" + group: "{{ user.stdout }}" + recurse: true + become: true + +- name: Remove test images from localhost + docker_image: + name: "{{ item }}" + state: absent + with_items: "{{ test_images }}" + become: true + + + diff --git a/ansible/setup-images.yml b/ansible/setup-images.yml new file mode 100644 index 00000000..8a639122 --- /dev/null +++ b/ansible/setup-images.yml @@ -0,0 +1,7 @@ +--- +- hosts: localhost + roles: + - {role: setup-test-images} + + +