Mount extra 80Gb volume

This PS mounts extra 80Gb volume if available and mounts it to
/opt/ext_vol. It also alters docker and containerd configs to move their
root folder to that extra volume. This helps zuul gates to succeed when
a node with 40Gb volume is assigned to a zuul gate.

Change-Id: I1c91b13c233bac5ebfe6e3cb16d4288df2c2fe80
This commit is contained in:
Sergiy Markin 2023-10-23 17:01:23 +00:00
parent 07c735f632
commit f9b0360418
8 changed files with 86 additions and 2 deletions

View File

@ -14,4 +14,5 @@
- hosts: all
roles:
- start-zuul-console
- mount-extra-volume
...

View File

@ -13,4 +13,8 @@
kubectl:
user: zuul
group: zuul
docker:
root_path: /var/lib/docker
containerd:
root_path: /var/lib/containerd
...

View File

@ -3,7 +3,7 @@ imports = []
oom_score = 0
plugin_dir = ""
required_plugins = []
root = "/var/lib/containerd"
root = "{{ containerd.root_path }}"
state = "/run/containerd"
temp = ""
version = 2

View File

@ -1,4 +1,5 @@
{
"data-root": "{{ docker.root_path }}",
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {

View File

@ -54,7 +54,7 @@
executable: /bin/bash
- name: Configure Docker daemon
copy:
template:
src: files/daemon.json
dest: /etc/docker/daemon.json

View File

@ -0,0 +1,18 @@
# 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.
---
extra_volume:
size: 80G
type: Linux
mount_point: /opt/ext_vol
...

View File

@ -0,0 +1,52 @@
# 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: Mount additional {{ extra_volume.size }} volume if available
when:
- ansible_distribution == 'Ubuntu'
- (ansible_mounts|selectattr("mount", "equalto", "/")|list)[0].size_available < 50000000000
block:
- name: Mount additional {{ extra_volume.size }} volume if available
shell: |
set -ex
sudo fdisk --list
df -h
sudo mkdir -p ${EXTRA_VOLUME_MOUNT_POINT}
BIG_VOLUME=$(sudo fdisk -l 2>&1 | grep -E ${EXTRA_VOLUME_SIZE} | grep ${EXTRA_VOLUME_TYPE} | awk '{print $1}')
if ! mount | grep "${BIG_VOLUME}"
then
sudo mkfs.ext4 "${BIG_VOLUME}"
sudo mount "${BIG_VOLUME}" ${EXTRA_VOLUME_MOUNT_POINT}
df -h
fi
environment:
EXTRA_VOLUME_MOUNT_POINT: "{{ extra_volume.mount_point }}"
EXTRA_VOLUME_SIZE: "{{ extra_volume.size }}"
EXTRA_VOLUME_TYPE: "{{ extra_volume.type }}"
- name: Print configured docker root path
debug:
msg: "Docker root_path: {{ docker.root_path }}"
- name: Print configured containerd root path
debug:
msg: "containerd root_path: {{ containerd.root_path }}"
- name: Create mountpoints
shell: |
sudo mkdir -pv "${DOCKER_ROOT_PATH}"
sudo mkdir -pv "${CONTAINERD_ROOT_PATH}"
environment:
DOCKER_ROOT_PATH: "{{ docker.root_path }}"
CONTAINERD_ROOT_PATH: "{{ containerd.root_path }}"
...

View File

@ -83,6 +83,14 @@
- playbooks/deploy-env.yaml
- playbooks/run-scripts.yaml
vars:
extra_volume:
size: 80G
type: Linux
mount_point: /opt/ext_vol
docker:
root_path: "/opt/ext_vol/docker"
containerd:
root_path: "/opt/ext_vol/containerd"
# the k8s package versions are available here
# https://packages.cloud.google.com/apt/dists/kubernetes-xenial/main/binary-amd64/Packages
kube_version: "1.26.3-00"