-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3242 from ingvagabund/create-node-upgrade-role
Move current node upgrade tasks under openshift_node_upgrade role
- Loading branch information
Showing
16 changed files
with
531 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
OpenShift/Atomic Enterprise Node upgrade | ||
========= | ||
|
||
Role responsible for a single node upgrade. | ||
It is expected a node is functioning and a part of an OpenShift cluster. | ||
|
||
Requirements | ||
------------ | ||
|
||
TODO | ||
|
||
Role Variables | ||
-------------- | ||
From this role: | ||
|
||
| Name | Default value | | | ||
|--------------------------------|-----------------------|--------------------------------------------------------| | ||
| deployment_type | | Inventory var | | ||
| docker_upgrade_nuke_images | | Optional inventory var | | ||
| docker_version | | Optional inventory var | | ||
| l_docker_upgrade | | | | ||
| node_config_hook | | | | ||
| openshift.docker.gte_1_10 | | | | ||
| openshift_image_tag | | Set by openshift_version role | | ||
| openshift_pkg_version | | Set by openshift_version role | | ||
| openshift_release | | Set by openshift_version role | | ||
| skip_docker_restart | | | | ||
| openshift_cloudprovider_kind | | | | ||
|
||
From openshift.common: | ||
|
||
| Name | Default Value | | | ||
|------------------------------------|---------------------|---------------------| | ||
| openshift.common.config_base |---------------------|---------------------| | ||
| openshift.common.data_dir |---------------------|---------------------| | ||
| openshift.common.hostname |---------------------|---------------------| | ||
| openshift.common.http_proxy |---------------------|---------------------| | ||
| openshift.common.is_atomic |---------------------|---------------------| | ||
| openshift.common.is_containerized |---------------------|---------------------| | ||
| openshift.common.portal_net |---------------------|---------------------| | ||
| openshift.common.service_type |---------------------|---------------------| | ||
| openshift.common.use_openshift_sdn |---------------------|---------------------| | ||
|
||
From openshift.master: | ||
|
||
| Name | Default Value | | | ||
|------------------------------------|---------------------|---------------------| | ||
| openshift.master.api_port |---------------------|---------------------| | ||
|
||
From openshift.node: | ||
|
||
| Name | Default Value | | | ||
|------------------------------------|---------------------|---------------------| | ||
| openshift.node.debug_level |---------------------|---------------------| | ||
| openshift.node.node_image |---------------------|---------------------| | ||
| openshift.node.ovs_image |---------------------|---------------------| | ||
|
||
|
||
Dependencies | ||
------------ | ||
openshift_common | ||
|
||
TODO | ||
|
||
Example Playbook | ||
---------------- | ||
|
||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: | ||
|
||
``` | ||
--- | ||
- name: Upgrade nodes | ||
hosts: oo_nodes_to_upgrade | ||
serial: 1 | ||
any_errors_fatal: true | ||
pre_tasks: | ||
- name: Mark unschedulable | ||
command: > | ||
{{ hostvars[groups.oo_first_master.0].openshift.common.client_binary }} adm manage-node {{ openshift.node.nodename | lower }} --schedulable=false | ||
delegate_to: "{{ groups.oo_first_master.0 }}" | ||
- name: Drain Node for Kubelet upgrade | ||
command: > | ||
{{ hostvars[groups.oo_first_master.0].openshift.common.admin_binary }} drain {{ openshift.node.nodename | lower }} --force --delete-local-data | ||
delegate_to: "{{ groups.oo_first_master.0 }}" | ||
roles: | ||
- openshift_facts | ||
- docker | ||
- openshift_node_upgrade | ||
post_tasks: | ||
- name: Set node schedulability | ||
command: > | ||
{{ hostvars[groups.oo_first_master.0].openshift.common.client_binary }} adm manage-node {{ openshift.node.nodename | lower }} --schedulable=true | ||
delegate_to: "{{ groups.oo_first_master.0 }}" | ||
``` | ||
|
||
License | ||
------- | ||
|
||
Apache License, Version 2.0 | ||
|
||
Author Information | ||
------------------ | ||
|
||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# Stop any running containers | ||
running_container_ids=`docker ps -q` | ||
if test -n "$running_container_ids" | ||
then | ||
docker stop $running_container_ids | ||
fi | ||
|
||
# Delete all containers | ||
container_ids=`docker ps -a -q` | ||
if test -n "$container_ids" | ||
then | ||
docker rm -f -v $container_ids | ||
fi | ||
|
||
# Delete all images (forcefully) | ||
image_ids=`docker images -aq` | ||
if test -n "$image_ids" | ||
then | ||
# Some layers are deleted recursively and are no longer present | ||
# when docker goes to remove them: | ||
docker rmi -f `docker images -aq` || true | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
- name: restart openvswitch | ||
systemd: name=openvswitch state=restarted | ||
when: (not skip_node_svc_handlers | default(False) | bool) and not (ovs_service_status_changed | default(false) | bool) and openshift.common.use_openshift_sdn | bool | ||
notify: | ||
- restart openvswitch pause | ||
|
||
- name: restart openvswitch pause | ||
pause: seconds=15 | ||
when: (not skip_node_svc_handlers | default(False) | bool) and openshift.common.is_containerized | bool | ||
|
||
- name: restart node | ||
systemd: name={{ openshift.common.service_type }}-node state=restarted | ||
when: (not skip_node_svc_handlers | default(False) | bool) and not (node_service_status_changed | default(false) | bool) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
galaxy_info: | ||
author: your name | ||
description: OpenShift Node upgrade | ||
company: Red Hat, Inc. | ||
license: Apache License, Version 2.0 | ||
min_ansible_version: 2.1 | ||
platforms: | ||
- name: EL | ||
versions: | ||
- 7 | ||
dependencies: | ||
- role: openshift_common |
14 changes: 14 additions & 0 deletions
14
roles/openshift_node_upgrade/tasks/containerized_node_upgrade.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
# This is a hack to allow us to use systemd_units.yml, but skip the handlers which | ||
# restart services. We will unconditionally restart all containerized services | ||
# because we have to unconditionally restart Docker: | ||
- set_fact: | ||
skip_node_svc_handlers: True | ||
|
||
- name: Update systemd units | ||
include: systemd_units.yml | ||
|
||
# This is a no-op because of skip_node_svc_handlers, but lets us trigger it before end of | ||
# play when the node has already been marked schedulable again. (this would look strange | ||
# in logs otherwise) | ||
- meta: flush_handlers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
# input variables: | ||
# - openshift.common.service_type | ||
# - openshift.common.is_containerized | ||
# - openshift.common.hostname | ||
# - openshift.master.api_port | ||
|
||
- name: Restart docker | ||
service: name=docker state=restarted | ||
|
||
- name: Update docker facts | ||
openshift_facts: | ||
role: docker | ||
|
||
- name: Restart containerized services | ||
service: name={{ item }} state=started | ||
with_items: | ||
- etcd_container | ||
- openvswitch | ||
- "{{ openshift.common.service_type }}-master" | ||
- "{{ openshift.common.service_type }}-master-api" | ||
- "{{ openshift.common.service_type }}-master-controllers" | ||
- "{{ openshift.common.service_type }}-node" | ||
failed_when: false | ||
when: openshift.common.is_containerized | bool | ||
|
||
- name: Wait for master API to come back online | ||
wait_for: | ||
host: "{{ openshift.common.hostname }}" | ||
state: started | ||
delay: 10 | ||
port: "{{ openshift.master.api_port }}" | ||
when: inventory_hostname in groups.oo_masters_to_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
# input variables: | ||
# - openshift.common.service_type | ||
# - openshift.common.is_containerized | ||
# - docker_upgrade_nuke_images | ||
# - docker_version | ||
# - skip_docker_restart | ||
|
||
# We need docker service up to remove all the images, but these services will keep | ||
# trying to re-start and thus re-pull the images we're trying to delete. | ||
- name: Stop containerized services | ||
service: name={{ item }} state=stopped | ||
with_items: | ||
- "{{ openshift.common.service_type }}-master" | ||
- "{{ openshift.common.service_type }}-master-api" | ||
- "{{ openshift.common.service_type }}-master-controllers" | ||
- "{{ openshift.common.service_type }}-node" | ||
- etcd_container | ||
- openvswitch | ||
failed_when: false | ||
when: openshift.common.is_containerized | bool | ||
|
||
- name: Check Docker image count | ||
shell: "docker images -aq | wc -l" | ||
register: docker_image_count | ||
|
||
- debug: var=docker_image_count.stdout | ||
|
||
# TODO(jchaloup): put all docker_upgrade_nuke_images into a block with only one condition | ||
- name: Remove all containers and images | ||
script: nuke_images.sh | ||
register: nuke_images_result | ||
when: docker_upgrade_nuke_images is defined and docker_upgrade_nuke_images | bool | ||
|
||
- name: Check Docker image count | ||
shell: "docker images -aq | wc -l" | ||
register: docker_image_count | ||
when: docker_upgrade_nuke_images is defined and docker_upgrade_nuke_images | bool | ||
|
||
- debug: var=docker_image_count.stdout | ||
when: docker_upgrade_nuke_images is defined and docker_upgrade_nuke_images | bool | ||
|
||
- service: name=docker state=stopped | ||
|
||
- name: Upgrade Docker | ||
package: name=docker{{ '-' + docker_version }} state=present | ||
|
||
- include: restart.yml | ||
when: not skip_docker_restart | default(False) | bool |
Oops, something went wrong.