Merge "Add missing 'update_tasks' to the OVN dbs pacemaker service"

This commit is contained in:
Zuul 2018-06-16 17:06:57 +00:00 committed by Gerrit Code Review
commit 6138a4499a
2 changed files with 175 additions and 1 deletions

View File

@ -88,7 +88,13 @@ outputs:
config_settings: config_settings:
map_merge: map_merge:
- get_attr: [OVNDbsBase, role_data, config_settings] - get_attr: [OVNDbsBase, role_data, config_settings]
- tripleo::profile::pacemaker::ovn_dbs_bundle::ovn_dbs_docker_image: {get_param: DockerOvnDbsImage} - tripleo::profile::pacemaker::ovn_dbs_bundle::ovn_dbs_docker_image: &ovn_dbs_image_pcmklatest
list_join:
- ':'
- - yaql:
data: {get_param: DockerOvnDbsImage}
expression: $.data.rightSplit(separator => ":", maxSplits => 1)[0]
- 'pcmklatest'
- tripleo::profile::pacemaker::ovn_dbs_bundle::nb_db_port: {get_param: OVNNorthboundServerPort} - tripleo::profile::pacemaker::ovn_dbs_bundle::nb_db_port: {get_param: OVNNorthboundServerPort}
- tripleo::profile::pacemaker::ovn_dbs_bundle::sb_db_port: {get_param: OVNSouthboundServerPort} - tripleo::profile::pacemaker::ovn_dbs_bundle::sb_db_port: {get_param: OVNSouthboundServerPort}
logging_source: {get_attr: [OVNDbsBase, role_data, logging_source]} logging_source: {get_attr: [OVNDbsBase, role_data, logging_source]}
@ -115,6 +121,29 @@ outputs:
optional: true optional: true
docker_config_scripts: {get_attr: [ContainersCommon, docker_config_scripts]} docker_config_scripts: {get_attr: [ContainersCommon, docker_config_scripts]}
docker_config: docker_config:
step_2:
ovn_dbs_image_tag:
start_order: 0
detach: false
net: host
user: root
command:
- '/bin/bash'
- '-c'
- str_replace:
template:
"/usr/bin/docker tag 'OVN_DBS_IMAGE' 'OVN_DBS_IMAGE_PCMKLATEST'"
params:
OVN_DBS_IMAGE: {get_param: DockerOvnDbsImage}
OVN_DBS_IMAGE_PCMKLATEST: *ovn_dbs_image_pcmklatest
image: {get_param: DockerOvnDbsImage}
volumes:
- /etc/hosts:/etc/hosts:ro
- /etc/localtime:/etc/localtime:ro
- /dev/shm:/dev/shm:rw
- /etc/sysconfig/docker:/etc/sysconfig/docker:ro
- /usr/bin:/usr/bin:ro
- /var/run/docker.sock:/var/run/docker.sock:rw
step_3: step_3:
ovn_dbs_restart_bundle: ovn_dbs_restart_bundle:
start_order: 0 start_order: 0
@ -182,7 +211,145 @@ outputs:
Log files from openvswitch containers can be found under Log files from openvswitch containers can be found under
/var/log/containers/openvswitch. /var/log/containers/openvswitch.
ignore_errors: true ignore_errors: true
update_tasks:
- name: Get docker ovn-dbs image
set_fact:
ovn_dbs_docker_image: {get_param: DockerOvnDbsImage}
ovn_dbs_docker_image_latest: *ovn_dbs_image_pcmklatest
- name: Check for ovn-dbs log file
stat:
path: /var/log/containers/openvswitch/ovsdb-server-nb.log
register: ovn_dbs_log_file
- name: Check if ovn-dbs is already containerized
set_fact:
ovn_dbs_containerized: "{{ovn_dbs_log_file.stat.exists | default(false)}}"
- name: get bootstrap nodeid
command: hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid
register: bootstrap_node
- name: set is_bootstrap_node fact
set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
- name: ovn-dbs fetch and retag container image for pacemaker
when:
- step|int == 3
- ovn_dbs_containerized|bool
block: &ovn_dbs_fetch_retag_container_tasks
- name: Get previous ovn-dbs image id
shell: "docker images | awk '/ovn.* pcmklatest/{print $3}' | uniq"
register: ovn_dbs_image_id
- block:
- name: Get a list of container using ovn-dbs image
shell: "docker ps -a -q -f 'ancestor={{ovn_dbs_image_id.stdout}}'"
register: ovn_dbs_containers_to_destroy
# It will be recreated with the deploy step.
- name: Remove any container using the same ovn-dbs image
shell: "docker rm -fv {{item}}"
with_items: "{{ ovn_dbs_containers_to_destroy.stdout_lines }}"
- name: Remove previous ovn-dbs images
shell: "docker rmi -f {{ovn_dbs_image_id.stdout}}"
when:
- ovn_dbs_image_id.stdout != ''
- name: Pull latest ovn-dbs images
command: "docker pull {{ovn_dbs_docker_image}}"
- name: Retag pcmklatest to latest ovn-dbs image
shell: "docker tag {{ovn_dbs_docker_image}} {{ovn_dbs_docker_image_latest}}"
# Got to check that pacemaker_is_active is working fine with bundle.
# TODO: pacemaker_is_active resource doesn't support bundle.
# When ovn-dbs-bundle support was added, we didn't tag the ovn-dbs image
# with pcmklatest. So, when update is run for the first time we need to
# update the ovn-dbs-bundle resource to use the 'pcmklatest' tagged image.
# See https://bugzilla.redhat.com/show_bug.cgi?id=1586132.
# Step 3 (see above) takes care of tagging the image.
- name: Update ovn-dbs-bundle resource to use pcmklatest tag image if not used
when:
- step|int == 5
- ovn_dbs_containerized|bool
- is_bootstrap_node
block:
- name: Get the present image used by ovn-dbs-bundle
shell: "pcs resource show ovn-dbs-bundle | grep image | awk '{ split($2, image, \"=\"); print image[2] }'"
register: ovn_dbs_current_image
- block: &ovn_dbs_update_bundle_with_new_image
- name: Disable the ovn-dbs-bundle resource before updating the image
pacemaker_resource:
resource: ovn-dbs-bundle
state: disable
wait_for_resource: true
register: output
retries: 5
until: output.rc == 0
- name: Update the ovn-dbs-bundle to use the new container image name
command: "pcs resource bundle update ovn-dbs-bundle container image={{ovn_dbs_docker_image_latest}}"
- name: Enable the ovn-dbs-bundle resource
pacemaker_resource:
resource: ovn-dbs-bundle
state: enable
wait_for_resource: true
register: output
retries: 5
until: output.rc == 0
when:
- ovn_dbs_current_image.stdout != ovn_dbs_docker_image_latest
upgrade_tasks: upgrade_tasks:
- name: Stop and disable ovn-northd service - name: Stop and disable ovn-northd service
when: step|int == 1 when: step|int == 1
service: name=ovn-northd state=stopped enabled=no service: name=ovn-northd state=stopped enabled=no
ignore_errors: true
- name: Check for ovn-dbs log file
stat:
path: /var/log/containers/openvswitch/ovsdb-server-nb.log
register: ovn_dbs_log_file
- name: Check if ovn-dbs is already containerized
set_fact:
ovn_dbs_containerized: "{{ovn_dbs_log_file.stat.exists | default(false)}}"
- name: Get docker ovn-dbs image
set_fact:
ovn_dbs_docker_image: {get_param: DockerOvnDbsImage}
ovn_dbs_docker_image_latest: *ovn_dbs_image_pcmklatest
- name: get bootstrap nodeid
command: hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid
register: bootstrap_node
- name: set is_bootstrap_node fact
set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
- name: Prepare the switch to new ovn-dbs container image name in pacemaker
when:
- step|int == 0
- ovn_dbs_containerized|bool
block:
- name: Get ovn-dbs image id currently used by pacemaker
shell: "docker images | awk '/ovn.* pcmklatest/{print $3}' | uniq"
register: ovn_dbs_current_pcmklatest_id
- name: Temporarily tag the current ovn-dbs pcmklatest image id with the upgraded image name
shell: "docker tag {{ovn_dbs_current_pcmklatest_id.stdout}} {{ovn_dbs_docker_image_latest}}"
when: ovn_dbs_current_pcmklatest_id.stdout != ''
# If ovn-dbs image is not tagged with pcmklatest, then create a new
# tag. This could happen if the stack is upgraded without updating the stack before.
# In the next step, the block 'ovn_dbs_update_bundle_with_new_image'
# will update the ovn-dbs-bundle resource to use the tagged image.
# And in step 3, we will fetch the latest image.
- block:
- name: Get the present image used by ovn-dbs-bundle
shell: "pcs resource show ovn-dbs-bundle | grep image | awk '{ split($2, image, \"=\"); print image[2] }'"
register: ovn_dbs_current_image
- name: Tag the current image with pcmklatest tag
shell: "docker tag {{ovn_dbs_current_image.stdout}} {{ovn_dbs_docker_image_latest}}"
when:
- ovn_dbs_current_pcmklatest_id.stdout == ''
- name: Check ovn-dbs-bundle cluster resource status
pacemaker_resource:
resource: ovn-dbs-bundle
state: show
check_mode: false
ignore_errors: true
register: ovndbs_pcs_res
- name: Update ovn-bundle pcs resource bundle for new container image
when:
- step|int == 1
- ovn_dbs_containerized|bool
- is_bootstrap_node
- ovndbs_pcs_res|succeeded
block: *ovn_dbs_update_bundle_with_new_image
- name: Retag the pacemaker image if containerized
when:
- step|int == 3
- ovn_dbs_containerized|bool
block: *ovn_dbs_fetch_retag_container_tasks

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Fixes minor updates issue for ovn dbs pacemaker bundle resource by tagging
the docker image used for ovn dbs pacemaker resource with pcmklatest and
adding required missing tasks in "update_tasks" and "upgrade_tasks"
section of the service file.