From 4bba417801d103832c97002753305b086b2481a2 Mon Sep 17 00:00:00 2001 From: clore Date: Sun, 8 Dec 2024 08:29:24 +0000 Subject: [PATCH] ensure packages before xfs migration --- lib/xfs.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/xfs.py b/lib/xfs.py index 459d9b0..50ad490 100644 --- a/lib/xfs.py +++ b/lib/xfs.py @@ -1,8 +1,10 @@ # Library to setup XFS partition for docker +from lib import ensure_packages_installed from lib import logging as logging_lib from lib import docker_interface from lib import utils +import asyncio import json import os @@ -16,6 +18,15 @@ MIN_XFS_PARTITION_SIZE = 1024*24 # 24 GB XFS_STATE_FILE = "/opt/clore-hosting/xfs_state" +MANDATORY_PACKAGES = [ + "xfsprogs", + "dmidecode", + "openvpn", + "iproute2", + "iputils-ping", + "util-linux" +] + # This code is runned on start of clore hosting to migrate docker to XFS partition system # sudo fallocate -l 300G /docker-storage.img @@ -29,6 +40,13 @@ def migrate(): return elif docker_xfs_state == "valid": return 'success' + + packages_available = asyncio.run(ensure_packages_installed.ensure_packages_installed( + MANDATORY_PACKAGES + )) + + if not packages_available: + return 'packages-missing' log.info("Starting migration to xfs") docker_interface.stop_all_containers() @@ -80,7 +98,7 @@ def migrate(): def validate_docker_xfs(): code_root, stdout_root, stderr_root = utils.run_command("df -T /") code, stdout, stderr = utils.run_command(f"df -T {DOCKER_ROOT}") - print([code, stderr, stdout]) + #print([code, stderr, stdout]) if code_root == 0 and stderr_root == '' and ((code == 0 and stderr == '') or (code == 1 and f" {DOCKER_ROOT}: " in stderr and stdout == '')): root_blocks = None docker_root_blocks = None