Move data device detection to Ansible
Move the detection of the secondary data disk device to the bootstrap-host role. This is important because the detection was previously done in bash in the gate-check-commit, but since bootstrap-aio is executed independently of gate-check-commit in the gate, the data disk is no longer being used correctly. Now the data disk will bootstrap reliably regardless of how bootstrap-aio is run. Change-Id: I2d49b6802d8cf99f6d7ac74ae4ce0ab8f6d1c7a5
This commit is contained in:
parent
fda2de4eb6
commit
4bc3e429c5
@ -29,6 +29,14 @@ cd "$(dirname "${0}")/.."
|
||||
|
||||
## Main ----------------------------------------------------------------------
|
||||
|
||||
# When running in the gate, enable data device detection in the bootstrap
|
||||
# role. This is needed on RAX nodepool instances because the root data disk
|
||||
# is too small for an OSA AIO, and a second data disk is attached which must
|
||||
# be formatted and used.
|
||||
if [[ -d '/etc/nodepool' ]]; then
|
||||
export BOOTSTRAP_HOST_DETECT_DATA_DISK=true
|
||||
fi
|
||||
|
||||
# Ensure that some of the wrapper options are overridden
|
||||
# to prevent interference with the AIO bootstrap.
|
||||
export ANSIBLE_INVENTORY="${OSA_CLONE_DIR}/tests/test-inventory.ini"
|
||||
|
@ -81,17 +81,6 @@ log_instance_info
|
||||
|
||||
run_dstat || true
|
||||
|
||||
# Get minimum disk size
|
||||
DATA_DISK_MIN_SIZE="$((1024**3 * $(awk '/bootstrap_host_data_disk_min_size/{print $2}' "${OSA_CLONE_DIR}/tests/roles/bootstrap-host/defaults/main.yml") ))"
|
||||
|
||||
# Determine the largest secondary disk device that meets the minimum size
|
||||
DATA_DISK_DEVICE=$(lsblk -brndo NAME,TYPE,RO,SIZE | awk '/d[b-z]+ disk 0/{ if ($4>m && $4>='$DATA_DISK_MIN_SIZE'){m=$4; d=$1}}; END{print d}')
|
||||
|
||||
# Only set the secondary disk device option if there is one
|
||||
if [ -n "${DATA_DISK_DEVICE}" ]; then
|
||||
export BOOTSTRAP_OPTS="${BOOTSTRAP_OPTS} bootstrap_host_data_disk_device=${DATA_DISK_DEVICE}"
|
||||
fi
|
||||
|
||||
# If in OpenStack-Infra, set some vars to use the mirror when bootstrapping Ansible
|
||||
if [[ -e /etc/ci/mirror_info.sh ]]; then
|
||||
source /etc/ci/mirror_info.sh
|
||||
|
@ -134,10 +134,17 @@ bootstrap_host_ip_path: "{{ bootstrap_host_network_utils[ansible_pkg_mgr]['ip']
|
||||
# WARNING: The data on a secondary storage device specified here will
|
||||
# be destroyed and repartitioned.
|
||||
#
|
||||
|
||||
# Enable detection for the secondary data disk
|
||||
# This does not run by default, but gate-check-commit and the OSA gate jobs
|
||||
# enable this because it is needed for RAX nodepool instances
|
||||
bootstrap_host_data_disk_device_detect: "{{ lookup('env', 'BOOTSTRAP_HOST_DETECT_DATA_DISK') |
|
||||
default(False, True) }}"
|
||||
|
||||
# Specify the secondary disk device to use. When the data disk is in use, no NOT
|
||||
# set the full path to the device. IE: "/dev/xvde" should be "xvde".
|
||||
bootstrap_host_data_disk_device: null
|
||||
#
|
||||
|
||||
# Specify the default filesystem type
|
||||
bootstrap_host_data_disk_fs_type: ext4
|
||||
#
|
||||
|
27
tests/roles/bootstrap-host/tasks/detect_data_disk_device.yml
Normal file
27
tests/roles/bootstrap-host/tasks/detect_data_disk_device.yml
Normal file
@ -0,0 +1,27 @@
|
||||
---
|
||||
# Copyright 2019, Logan Vig <logan2211@gmail.com>
|
||||
#
|
||||
# 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: Locate data disk candidates
|
||||
shell: >
|
||||
lsblk -brndo NAME,TYPE,RO,SIZE |
|
||||
awk '/d[b-z]+ disk 0/{ if ($4>m && $4>={{ bootstrap_host_data_disk_min_size }}){m=$4; d=$1}}; END{print d}'
|
||||
changed_when: false
|
||||
register: _data_disk
|
||||
|
||||
- name: Set the data disk device
|
||||
set_fact:
|
||||
bootstrap_host_data_disk_device: "{{ _data_disk.stdout }}"
|
||||
when:
|
||||
- _data_disk.stdout != ''
|
@ -13,6 +13,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Attempt data device detection if enabled
|
||||
- include_tasks: detect_data_disk_device.yml
|
||||
when:
|
||||
- bootstrap_host_data_disk_device is none
|
||||
- bootstrap_host_data_disk_device_detect | bool
|
||||
|
||||
# Before we do anything, check the minimum requirements
|
||||
- include: check-requirements.yml
|
||||
tags:
|
||||
|
Loading…
x
Reference in New Issue
Block a user