]> review.fuel-infra Code Review - tools/sustaining.git/commitdiff
Enhance slave deploy job with per-cloud templates 89/41389/7
authorVladimir Khlyunev <vkhlyunev@mirantis.com>
Mon, 22 Jul 2019 11:15:00 +0000 (15:15 +0400)
committerVladimir Khlyunev <vkhlyunev@mirantis.com>
Tue, 23 Jul 2019 10:28:59 +0000 (14:28 +0400)
For EU cloud we want to pin mos executors to specific set of compute hosts

Change-Id: I1ef8528f554b9258b3818608f469fa1f09ad4b11

12 files changed:
maintenance-ci/common/data/mos-dev-slave-eu.yml [new file with mode: 0644]
maintenance-ci/common/data/mos-dev-slave-us.yml [moved from maintenance-ci/common/data/mos-dev-slave.yml with 100% similarity]
maintenance-ci/common/data/mos-slave-eu.yml [moved from maintenance-ci/common/data/mos-slave.yml with 81% similarity]
maintenance-ci/common/data/mos-slave-us.yml [new file with mode: 0644]
maintenance-ci/common/jobs/deploy-jenkins-swarm.yaml
maintenance-ci/common/jobs/deploy-stack.yaml
maintenance-ci/common/jobs/multijob-build-image.yaml
maintenance-ci/common/macroses/mos-jenkins-swarm-params.yaml
maintenance-ci/common/scripts/deploy_heat_stack.sh
maintenance-ci/common/scripts/update_jenkins_jobs.sh
maintenance-ci/mos/macroses/9x-systest-params.yaml
maintenance-ci/mos/scripts/fuel_qa_launch_test.sh

diff --git a/maintenance-ci/common/data/mos-dev-slave-eu.yml b/maintenance-ci/common/data/mos-dev-slave-eu.yml
new file mode 100644 (file)
index 0000000..1cfd69f
--- /dev/null
@@ -0,0 +1,161 @@
+
+heat_template_version: 2017-09-01
+
+parameters:
+  key_name:
+    type: string
+    description: Name of keypair to assign to servers
+    default: maintenance-ci-public-key
+    constraints:
+      - custom_constraint: nova.keypair
+        description: Must name a public key (pair) known to Nova
+  image:
+    type: string
+    description: Name of image to use for servers
+    default: maintenance-ci-mos-image
+    constraints:
+      - custom_constraint: glance.image
+        description: Must identify an image known to Glance
+  flavor:
+    type: string
+    description: Flavor to use for servers
+    constraints:
+      - custom_constraint: nova.flavor
+        description: Must be a flavor known to Nova
+  public_net:
+    type: string
+    default: public
+    description: Id of the public network for the compute server
+  jenkins_labels:
+    type: string
+    default: ''
+    description: List of labels for jenkins swarm agent separated by whitespace
+  location:
+    type: string
+    default: 'EU'
+    description: Backend cluster location (available "EU" and "US")
+
+resources:
+  wait_condition:
+    type: OS::Heat::WaitCondition
+    properties:
+      handle: {get_resource: wait_handle}
+      count: 1
+      timeout: 300
+
+  wait_handle:
+    type: OS::Heat::WaitConditionHandle
+
+  private_net:
+    type: OS::Neutron::Net
+
+  private_subnet:
+    type: OS::Neutron::Subnet
+    properties:
+      network_id: { get_resource: private_net }
+      cidr: 10.10.0.0/24
+      dns_nameservers:
+        - 172.18.176.6
+        - 172.18.208.44
+
+  router:
+    type: OS::Neutron::Router
+    properties:
+      external_gateway_info:
+        network: { get_param: public_net }
+
+  router_interface:
+    type: OS::Neutron::RouterInterface
+    properties:
+      router_id: { get_resource: router }
+      subnet_id: { get_resource: private_subnet }
+
+  security_group:
+    type: OS::Neutron::SecurityGroup
+    properties:
+      rules: [
+      {direction: ingress,
+       remote_ip_prefix: 0.0.0.0/0,
+       protocol: tcp,
+       port_range_min: 1,
+       port_range_max: 65535},
+      {direction: ingress,
+       remote_ip_prefix: 0.0.0.0/0,
+       protocol: udp,
+       port_range_min: 1,
+       port_range_max: 65535},
+      {remote_ip_prefix: 0.0.0.0/0,
+       protocol: icmp,
+       direction: ingress}]
+
+  public_port:
+    type: OS::Neutron::Port
+    properties:
+      network_id: { get_resource: private_net }
+      fixed_ips:
+      - subnet_id: { get_resource: private_subnet }
+      security_groups:
+      - { get_resource: security_group }
+
+  floating_ip:
+    type: OS::Neutron::FloatingIP
+    properties:
+      floating_network_id: { get_param: public_net }
+      port_id: { get_resource: public_port }
+
+  node:
+    type: OS::Nova::Server
+    properties:
+      image: { get_param: image }
+      availability_zone: nova
+      flavor: { get_param: flavor }
+      key_name: { get_param: key_name }
+      networks:
+        - port: { get_resource: public_port }
+      scheduler_hints:
+        query: '["in","$hypervisor_hostname",
+                      "cmp015.eu.intcloud.mirantis.net",
+                      "cmp016.eu.intcloud.mirantis.net",
+                      "cmp017.eu.intcloud.mirantis.net",
+                      "cmp018.eu.intcloud.mirantis.net",
+                      "cmp019.eu.intcloud.mirantis.net",
+                      "cmp020.eu.intcloud.mirantis.net",
+                      "cmp021.eu.intcloud.mirantis.net",
+                      "cmp022.eu.intcloud.mirantis.net",
+                      "cmp023.eu.intcloud.mirantis.net",
+                      "cmp024.eu.intcloud.mirantis.net",
+                      "cmp025.eu.intcloud.mirantis.net",
+                      "cmp026.eu.intcloud.mirantis.net",
+                      "cmp027.eu.intcloud.mirantis.net",
+                      "cmp028.eu.intcloud.mirantis.net",
+                      "cmp029.eu.intcloud.mirantis.net",
+                      "cmp030.eu.intcloud.mirantis.net"]'
+      user_data:
+        str_replace:
+          template: |
+            #!/bin/bash
+            mkdir -p /etc/jenkins-agent/
+            echo "LABELS" > /etc/jenkins-agent/labels
+            echo "127.0.0.1 $(hostname)" >> /etc/hosts
+            echo "FLOATING" > /etc/jenkins-agent/description
+            echo "OPENSTACK_ENVIRONMENT" > /etc/jenkins-agent/location
+
+            apt update
+            sed -i 's/^\(GRUB_CMDLINE_LINUX_DEFAULT=\).*$/\1\"console=tty1 console=ttyS0 noibrs noibpb nopti nospectre_v2 nospectre_v1 l1tf=off nospec_store_bypass_disable no_stf_barrier\"/g' /etc/default/grub.d/50-cloudimg-settings.cfg
+            apt install -y linux-generic-hwe-16.04 linux-tools-generic-hwe-16.04 linux-cloud-tools-generic-hwe-16.04 linux-tools-common
+            update-grub
+
+            systemctl enable jenkins-swarm-agent
+            wc_notify --data-binary '{"status": "SUCCESS"}'
+            reboot
+          params:
+           LABELS: {get_param: jenkins_labels}
+           wc_notify: { get_attr: [wait_handle, curl_cli] }
+           FLOATING: { get_attr: [ floating_ip, floating_ip_address ] }
+           OPENSTACK_ENVIRONMENT: {get_param: location}
+
+
+outputs:
+  floating_ip:
+      description: Floating IP
+      value: { get_attr: [ floating_ip, floating_ip_address ] }
similarity index 81%
rename from maintenance-ci/common/data/mos-slave.yml
rename to maintenance-ci/common/data/mos-slave-eu.yml
index 852a53ea4f55457d1e3e03e21dd7db8940daa23c..6b1bd6ceb78e91d00c54c2bd443e4acd9284aeba 100644 (file)
@@ -112,6 +112,24 @@ resources:
       key_name: { get_param: key_name }
       networks:
         - port: { get_resource: public_port }
+      scheduler_hints:
+        query: '["in","$hypervisor_hostname",
+                      "cmp015.eu.intcloud.mirantis.net",
+                      "cmp016.eu.intcloud.mirantis.net",
+                      "cmp017.eu.intcloud.mirantis.net",
+                      "cmp018.eu.intcloud.mirantis.net",
+                      "cmp019.eu.intcloud.mirantis.net",
+                      "cmp020.eu.intcloud.mirantis.net",
+                      "cmp021.eu.intcloud.mirantis.net",
+                      "cmp022.eu.intcloud.mirantis.net",
+                      "cmp023.eu.intcloud.mirantis.net",
+                      "cmp024.eu.intcloud.mirantis.net",
+                      "cmp025.eu.intcloud.mirantis.net",
+                      "cmp026.eu.intcloud.mirantis.net",
+                      "cmp027.eu.intcloud.mirantis.net",
+                      "cmp028.eu.intcloud.mirantis.net",
+                      "cmp029.eu.intcloud.mirantis.net",
+                      "cmp030.eu.intcloud.mirantis.net"]'
       user_data:
         str_replace:
           template: |
diff --git a/maintenance-ci/common/data/mos-slave-us.yml b/maintenance-ci/common/data/mos-slave-us.yml
new file mode 100644 (file)
index 0000000..6b1bd6c
--- /dev/null
@@ -0,0 +1,162 @@
+
+heat_template_version: 2017-09-01
+
+parameters:
+  key_name:
+    type: string
+    description: Name of keypair to assign to servers
+    default: maintenance-ci-public-key
+    constraints:
+      - custom_constraint: nova.keypair
+        description: Must name a public key (pair) known to Nova
+  image:
+    type: string
+    description: Name of image to use for servers
+    default: maintenance-ci-mos-image
+    constraints:
+      - custom_constraint: glance.image
+        description: Must identify an image known to Glance
+  flavor:
+    type: string
+    description: Flavor to use for servers
+    constraints:
+      - custom_constraint: nova.flavor
+        description: Must be a flavor known to Nova
+  public_net:
+    type: string
+    default: public
+    description: Id of the public network for the compute server
+  jenkins_labels:
+    type: string
+    default: ''
+    description: List of labels for jenkins swarm agent separated by whitespace
+  location:
+    type: string
+    default: 'EU'
+    description: Backend cluster location (available "EU" and "US")
+
+resources:
+  wait_condition:
+    type: OS::Heat::WaitCondition
+    properties:
+      handle: {get_resource: wait_handle}
+      count: 1
+      timeout: 300
+
+  wait_handle:
+    type: OS::Heat::WaitConditionHandle
+
+  private_net:
+    type: OS::Neutron::Net
+
+  private_subnet:
+    type: OS::Neutron::Subnet
+    properties:
+      network_id: { get_resource: private_net }
+      cidr: 10.10.0.0/24
+      dns_nameservers:
+        - 172.18.176.6
+        - 172.18.208.44
+
+  router:
+    type: OS::Neutron::Router
+    properties:
+      external_gateway_info:
+        network: { get_param: public_net }
+
+  router_interface:
+    type: OS::Neutron::RouterInterface
+    properties:
+      router_id: { get_resource: router }
+      subnet_id: { get_resource: private_subnet }
+
+  security_group:
+    type: OS::Neutron::SecurityGroup
+    properties:
+      rules: [
+      {direction: ingress,
+       remote_ip_prefix: 0.0.0.0/0,
+       protocol: tcp,
+       port_range_min: 1,
+       port_range_max: 65535},
+      {direction: ingress,
+       remote_ip_prefix: 0.0.0.0/0,
+       protocol: udp,
+       port_range_min: 1,
+       port_range_max: 65535},
+      {remote_ip_prefix: 0.0.0.0/0,
+       protocol: icmp,
+       direction: ingress}]
+
+  public_port:
+    type: OS::Neutron::Port
+    properties:
+      network_id: { get_resource: private_net }
+      fixed_ips:
+      - subnet_id: { get_resource: private_subnet }
+      security_groups:
+      - { get_resource: security_group }
+
+  floating_ip:
+    type: OS::Neutron::FloatingIP
+    properties:
+      floating_network_id: { get_param: public_net }
+      port_id: { get_resource: public_port }
+
+  node:
+    type: OS::Nova::Server
+    properties:
+      image: { get_param: image }
+      availability_zone: nova
+      flavor: { get_param: flavor }
+      key_name: { get_param: key_name }
+      networks:
+        - port: { get_resource: public_port }
+      scheduler_hints:
+        query: '["in","$hypervisor_hostname",
+                      "cmp015.eu.intcloud.mirantis.net",
+                      "cmp016.eu.intcloud.mirantis.net",
+                      "cmp017.eu.intcloud.mirantis.net",
+                      "cmp018.eu.intcloud.mirantis.net",
+                      "cmp019.eu.intcloud.mirantis.net",
+                      "cmp020.eu.intcloud.mirantis.net",
+                      "cmp021.eu.intcloud.mirantis.net",
+                      "cmp022.eu.intcloud.mirantis.net",
+                      "cmp023.eu.intcloud.mirantis.net",
+                      "cmp024.eu.intcloud.mirantis.net",
+                      "cmp025.eu.intcloud.mirantis.net",
+                      "cmp026.eu.intcloud.mirantis.net",
+                      "cmp027.eu.intcloud.mirantis.net",
+                      "cmp028.eu.intcloud.mirantis.net",
+                      "cmp029.eu.intcloud.mirantis.net",
+                      "cmp030.eu.intcloud.mirantis.net"]'
+      user_data:
+        str_replace:
+          template: |
+            #!/bin/bash
+            mkdir -p /etc/jenkins-agent/
+            echo "FLAVOR LABELS" > /etc/jenkins-agent/labels
+            echo "127.0.0.1 $(hostname)" >> /etc/hosts
+            echo "FLOATING" > /etc/jenkins-agent/description
+            echo "OPENSTACK_ENVIRONMENT" > /etc/jenkins-agent/location
+
+            apt update
+            sed -i 's/^\(GRUB_CMDLINE_LINUX_DEFAULT=\).*$/\1\"console=tty1 console=ttyS0 noibrs noibpb nopti nospectre_v2 nospectre_v1 l1tf=off nospec_store_bypass_disable no_stf_barrier\"/g' /etc/default/grub.d/50-cloudimg-settings.cfg
+            apt install -y linux-generic-hwe-16.04 linux-tools-generic-hwe-16.04 linux-cloud-tools-generic-hwe-16.04 linux-tools-common
+            update-grub
+
+            systemctl enable jenkins-swarm-agent
+            wc_notify --data-binary '{"status": "SUCCESS"}'
+            reboot
+          params:
+           FLAVOR: {get_param: flavor}
+           LABELS: {get_param: jenkins_labels}
+           wc_notify: { get_attr: [wait_handle, curl_cli] }
+           FLOATING: { get_attr: [ floating_ip, floating_ip_address ] }
+           OPENSTACK_ENVIRONMENT: {get_param: location}
+
+
+outputs:
+  floating_ip:
+      description: Floating IP
+      value: { get_attr: [ floating_ip, floating_ip_address ] }
index 8bb6b55e34257d04d6e28a30e509e4bd0722c2c2..9eb542d7dc12afed09fa49eefaa136883729ea12 100644 (file)
@@ -39,7 +39,7 @@
                 step: 1
               predefined-parameters: |
                   OPENSTACK_ENVIRONMENT=${OPENSTACK_ENVIRONMENT}
-                  HEAT_STACK_YAML=${CUSTOM_HEAT_STACK_YAML}
+                  CUSTOM_HEAT_STACK_YAML=${CUSTOM_HEAT_STACK_YAML}
                   STACK_PREFIX=${STACK_PREFIX}
                   FLAVOR_NAME=${CUSTOM_FLAVOR_NAME}
                   JENKINS_LABELS=${CUSTOM_FLAVOR_JENKINS_LABELS}
@@ -61,7 +61,7 @@
                   step: 1
               predefined-parameters: |
                     OPENSTACK_ENVIRONMENT=${OPENSTACK_ENVIRONMENT}
-                    HEAT_STACK_YAML=${HEAT_STACK_YAML}
+                    HEAT_STACK_TEMPLATE_NAME=${HEAT_STACK_TEMPLATE_NAME}
                     STACK_PREFIX=${STACK_PREFIX}
                     FLAVOR_NAME=mos.tempest
                     IMAGE_NAME=${IMAGE_NAME}
@@ -82,7 +82,7 @@
                 step: 1
               predefined-parameters: |
                     OPENSTACK_ENVIRONMENT=${OPENSTACK_ENVIRONMENT}
-                    HEAT_STACK_YAML=${HEAT_STACK_YAML}
+                    HEAT_STACK_TEMPLATE_NAME=${HEAT_STACK_TEMPLATE_NAME}
                     STACK_PREFIX=${STACK_PREFIX}
                     FLAVOR_NAME=mos.fuel.huge
                     IMAGE_NAME=${IMAGE_NAME}
                 step: 1
               predefined-parameters: |
                     OPENSTACK_ENVIRONMENT=${OPENSTACK_ENVIRONMENT}
-                    HEAT_STACK_YAML=${HEAT_STACK_YAML}
+                    HEAT_STACK_TEMPLATE_NAME=${HEAT_STACK_TEMPLATE_NAME}
                     STACK_PREFIX=${STACK_PREFIX}
                     FLAVOR_NAME=mos.fuel.base
                     IMAGE_NAME=${IMAGE_NAME}
index 1e08ab10fd206afaf41c8881bd1212fb17cf5784..ebef35e653a1f62ec85c80d28bfa0c7f7e52a467 100644 (file)
@@ -9,11 +9,15 @@
     parameters:
     - openstack-cloud-selector
     - choice:
-        name: HEAT_STACK_YAML
+        name: HEAT_STACK_TEMPLATE_NAME
         choices:
-            - "maintenance-ci/common/data/jenkins-slave.yml"
-            - "maintenance-ci/common/data/mos-slave.yml"
-            - "maintenance-ci/common/data/mos-dev-slave.yml"
+            - "mos-dev-slave"
+            - "jenkins-slave"
+            - "mos-slave"
+    - string:
+        name: CUSTOM_HEAT_STACK_YAML
+        description: "Overwrites HEAT_STACK_TEMPLATE_NAME with relative path to template file. Leave empty by default"
+        default: ""
     - string:
         name: STACK_PREFIX
         description: "Stack prefix"
index fdaa91563ef463af460245b6cffe8b4bc8bf3a5a..bf4c2933ca661b0d4c0baf5843e267740e09f16b 100644 (file)
@@ -36,7 +36,7 @@
         - project: "deploy-heat-stack"
           predefined-parameters: |
             OPENSTACK_ENVIRONMENT=${OPENSTACK_ENVIRONMENT}
-            HEAT_STACK_YAML=maintenance-ci/common/data/jenkins-slave.yml
+            HEAT_STACK_TEMPLATE_NAME=jenkins-slave
             STACK_PREFIX=image-builder
             FLAVOR_NAME=dev.cmn
             JENKINS_LABELS=image-builder
index e99b532b5f927e69f9ce44b1560d77024dd68bd5..f07145f73372fc030d28f6f04c903631f32db73f 100644 (file)
@@ -4,9 +4,9 @@
     parameters:
     - openstack-cloud-selector
     - string:
-        name: HEAT_STACK_YAML
-        description: "Stack yaml file"
-        default: "maintenance-ci/common/data/mos-slave.yml"
+        name: HEAT_STACK_TEMPLATE_NAME
+        description: "Stack yaml file name"
+        default: "mos-slave"
     - string:
         name: STACK_PREFIX
         description: "Stack prefix"
@@ -39,4 +39,7 @@
         default: ""
     - string:
         name: CUSTOM_FLAVOR_NODE_COUNT
-        default: "0"
\ No newline at end of file
+        default: "0"
+    - string:
+        name: GERRIT_REVIEW
+        default: ""
\ No newline at end of file
index ec3e12656d9a00f36fb3e9cc5a07d61cc2215a98..1daaa62cb352c9b575601bcd5a67a7f3d32fac74 100755 (executable)
@@ -2,6 +2,12 @@
 
 set -ex
 
+if [ ! -z ${GERRIT_REVIEW} ] ; then
+  refspec=$(curl "https://review.fuel-infra.org/changes/?q=${GERRIT_REVIEW}&o=CURRENT_REVISION" | grep '"ref":' | awk -F ": " '{print $2}' | tr -d '"')
+  git fetch https://review.fuel-infra.org/tools/sustaining "${refspec}" && git cherry-pick -n FETCH_HEAD
+fi
+
+
 OPENSTACK_CLIENTS_VENV="${OPENSTACK_CLIENTS_VENV:-/home/jenkins/venv-openstack-clients}"
 
 if [[ ! -d "${OPENSTACK_CLIENTS_VENV}" ]] ; then
@@ -32,11 +38,24 @@ fi
 
 STACK_NAME="${STACK_PREFIX:-swarm_slave}-${OPENSTACK_ENVIRONMENT,,}-$(head -c 100 /dev/urandom | "${md5_cmd}" | head -c 4)"
 
+if [[ ! -z "${CUSTOM_HEAT_STACK_YAML}" ]] ; then
+  TEMPLATE_FILE="${CUSTOM_HEAT_STACK_YAML}"
+elif [[ -f "${HEAT_STACK_YAML}" ]] ; then
+  TEMPLATE_FILE="${HEAT_STACK_YAML}"
+elif [[ ! -z "{HEAT_STACK_TEMPLATE_NAME}" ]] ; then
+  TEMPLATE_FILE="${WORKSPACE}/maintenance-ci/common/data/${HEAT_STACK_TEMPLATE_NAME}-${OPENSTACK_ENVIRONMENT,,}.yml"
+fi
+
+if [[ ! -f "${TEMPLATE_FILE}" ]] ; then
+  echo "Can not detect TEMPLATE_FILE file, nothing at ${TEMPLATE_FILE}, aborting"
+  exit 1
+fi
+
 set +x
 source "${OPENSTACK_CLIENTS_VENV}"/bin/activate
 set -x
   echo "Using ${OS_AUTH_URL?} endpoint"
-  openstack stack create --wait -t ${HEAT_STACK_YAML} --parameter "${parameter_string}" ${STACK_NAME}
+  openstack stack create --wait -t ${TEMPLATE_FILE} --parameter "${parameter_string}" ${STACK_NAME}
   openstack stack output show "${STACK_NAME}" --all
   cat >stack_data.sh <<EOF
 STACK_NAME=${STACK_NAME}
index 80e9e72b2608eadc5d115b62e3bbac81f000d96a..de4fdbbcbac4d70987988a3134d6fbd025fe57e2 100644 (file)
@@ -30,5 +30,5 @@ recursive=True
 param_order_from_yaml=true
 EOF
 
-jenkins-jobs --conf "${CONFIG_PATH}/jenkins_jobs.ini" update -x common/data "common:mos:mcp:views"
+jenkins-jobs --conf "${CONFIG_PATH}/jenkins_jobs.ini" update --workers 0 -x common/data "common:mos:mcp:views"
 popd
index 4d874e153dcf6a1e10b9b9576496c702470876bf..e8fd61b6dac431eaf0f03b7028effcb8407ed813 100644 (file)
@@ -45,7 +45,7 @@
         description: "fuel-qa commit"
         default: stable/mitaka
     - string:
-        name: GERRIT_REVIEW
+        name: FUEL_QA_GERRIT_REVIEW
         description: "gerrit review num"
         default: ""
 
index 34ead94c07048b9e049d1e4522a09f0047704857..52dd31dcbaa41a5a210c9c98e1dd7a393bd7d47a 100644 (file)
@@ -38,8 +38,8 @@ echo "======================================================"
 echo "======================================================"
 set -x
 
-if [[ ! -z ${GERRIT_REVIEW} ]] ; then
-refspec=$(curl "https://review.fuel-infra.org/changes/?q=${GERRIT_REVIEW}&o=CURRENT_REVISION" | grep '"ref":' | awk -F ": " '{print $2}' | tr -d '"')
+if [[ ! -z ${FUEL_QA_GERRIT_REVIEW} ]] ; then
+refspec=$(curl "https://review.fuel-infra.org/changes/?q=${FUEL_QA_GERRIT_REVIEW}&o=CURRENT_REVISION" | grep '"ref":' | awk -F ": " '{print $2}' | tr -d '"')
 git fetch https://review.fuel-infra.org/openstack/fuel-qa "${refspec}" && git cherry-pick -n FETCH_HEAD
 fi