Create minor playbook to sync TZ data on upgrade

Keeping the timezone data in sync between containers and the host
machine should be done by default. This addition ensures that all
containers inherit the TZ data from the host they're running on.

Change-Id: I2803b4b6814680af39594e205fcf7be338a70091
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter
2016-10-13 15:46:45 -05:00
parent f17b28c6cc
commit 8af5bfcebc
5 changed files with 71 additions and 0 deletions

View File

@@ -221,6 +221,17 @@ See :ref:`old-hostname-compatibility` for details.
# openstack-ansible "${UPGRADE_PLAYBOOKS}/old-hostname-compatibility.yml"
Ensure TZ data is sync'd between hosts and containers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ensure all containers have the same TZ and the physical hosts.
See :ref:`lxc-container-tz-sync` for details.
.. code-block:: console
# openstack-ansible "${UPGRADE_PLAYBOOKS}/lxc-container-tz-sync.yml"
Perform a mariadb version upgrade
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -74,6 +74,14 @@ playbook is only needed for upgrades of in-place upgrades of existing nodes or
if a node is replaced or rebuilt it will be brought into the cluster using a
compliant hostname.
.. _lxc-container-tz-sync:
lxc-container-tz-sync.yml
~~~~~~~~~~~~~~~~~~~~~~~~~
This playbook ensures that all containers are running on the same TZ settings
as the physical host.
.. _setup-infra-playbook:
setup-infrastructure.yml

View File

@@ -0,0 +1,7 @@
---
upgrade:
- LXC containers will have their TZ data sync with their physical host
machines. This is being done because containers have been assumed to
use UTC while a host could be using something else. This causes issues
in some services like celiometer and can result in general time
differences in logging.

View File

@@ -180,6 +180,7 @@ function main {
# rebuild the repo servers
RUN_TASKS+=("repo-install.yml")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/old-hostname-compatibility.yml")
RUN_TASKS+=("${UPGRADE_PLAYBOOKS}/lxc-container-tz-sync.yml")
# explicitly perform mariadb upgrade
RUN_TASKS+=("galera-install.yml -e 'galera_upgrade=true'")
# explicitly perform controlled galera cluster restart

View File

@@ -0,0 +1,44 @@
---
# Copyright 2016, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Container time sync
hosts: "{{ lxc_host_group | default('lxc_hosts')}}"
gather_facts: false
max_fail_percentage: 20
user: root
tasks:
- name: Ensure localtime is in sync
shell: |
EXIT_CODE=0
for i in $(lxc-ls --running); do
CONTAINER_ROOT="/proc/$(lxc-info -n $i -p | awk '{print $2}')/root"
DATE_BEFORE="$(chroot ${CONTAINER_ROOT} date +%Z)"
rm "${CONTAINER_ROOT}/etc/localtime"
cp -fP /etc/localtime "${CONTAINER_ROOT}/etc/localtime"
DATE_AFTER="$(chroot ${CONTAINER_ROOT} date +%Z)"
echo $DATE_AFTER $DATE_BEFORE
if [ "${DATE_BEFORE}" != "${DATE_AFTER}" ]; then
export EXIT_CODE=3
fi
done
exit ${EXIT_CODE}
args:
executable: /bin/bash
register: tz_data
failed_when: tz_data.rc == 1
changed_when: tz_data.rc == 3
tags:
- lxc-containers-create