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
This commit is contained in:
Jeremy Stanley 2024-02-08 17:15:57 +00:00
parent 1bd482e062
commit b44cae0233
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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: