From b44cae02338aa0c14f10d6515a2bd5c83943618c Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Thu, 8 Feb 2024 17:15:57 +0000 Subject: [PATCH] Check launched server for x86-64-v2/sse4_2 support The "UBI" that the latest Keycloak images are based on has a glibc compiled to only work on x86-64-v2 systems, and in some regions we seem to sometimes get hypervisors reporting older processor architectures where it won't work. Check CPU flags for sse4_2 support as an indicator, and abort launching if it's not present. Change-Id: Ib0f482a939f94e801c82f3583e0a58dc4ca1f35c --- launch/src/opendev_launch/launch_node.py | 3 +++ launch/src/opendev_launch/sshclient.py | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/launch/src/opendev_launch/launch_node.py b/launch/src/opendev_launch/launch_node.py index cd297f6d5d..6cc938ea64 100755 --- a/launch/src/opendev_launch/launch_node.py +++ b/launch/src/opendev_launch/launch_node.py @@ -131,6 +131,9 @@ def bootstrap_server(server, key, name, volume_device, keep, ssh_client = utils.ssh_connect(ip, 'root', ssh_kwargs, timeout=timeout) + if "sse4_2" not in ssh_client.ssh('cat /proc/cpuinfo', quiet=True)[1]: + raise Exception("CPU does not support x86-64-v2 (sse4_2)") + if not ignore_ipv6: # Something up with RAX images that they have the ipv6 interface in # /etc/network/interfaces but eth0 hasn't noticed yet; reload it diff --git a/launch/src/opendev_launch/sshclient.py b/launch/src/opendev_launch/sshclient.py index 2af58e7ec6..99fc01c0d6 100644 --- a/launch/src/opendev_launch/sshclient.py +++ b/launch/src/opendev_launch/sshclient.py @@ -38,14 +38,16 @@ class SSHClient(object): client.connect(ip, username=username, password=password, pkey=pkey) self.client = client - def ssh(self, command, error_ok=False): + def ssh(self, command, error_ok=False, quiet=False): stdin, stdout, stderr = self.client.exec_command(command) print('--- ssh: "%s" ---' % command) - print(' -- stdout --') + if not quiet: + print(' -- stdout --') output = '' for x in stdout: output += x - sys.stdout.write(" | " + x) + if not quiet: + sys.stdout.write(" | " + x) ret = stdout.channel.recv_exit_status() print(" -- stderr --") for x in stderr: