From 88796a8936ca99f8eb03a483a02ee6b62139a60e Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Wed, 7 Aug 2019 16:10:51 +0200 Subject: [PATCH] Do not try to use zRAM devices for anything These devices are mapped into memory, but nonetheless can appear in lsblk output. Ignore them explicitly. Change-Id: I2bb595ef29abdc98bd887bdf41c3c7f64cc3a7e6 --- ironic_python_agent/hardware.py | 6 ++++++ ironic_python_agent/tests/unit/test_hardware.py | 3 ++- releasenotes/notes/no-zram-78cc6583f4f90a9c.yaml | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/no-zram-78cc6583f4f90a9c.yaml diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py index 25cfada9c..7c0636be7 100644 --- a/ironic_python_agent/hardware.py +++ b/ironic_python_agent/hardware.py @@ -305,6 +305,12 @@ def list_all_block_devices(block_type='disk', raise errors.BlockDeviceError( '%s must be returned by lsblk.' % ', '.join(sorted(missing))) + # NOTE(dtantsur): zRAM devices can appear in the output of lsblk, but + # we cannot do anything useful with them. + if device['KNAME'].startswith('zram'): + LOG.debug('Skipping zRAM device %s', device) + continue + name = os.path.join('/dev', device['KNAME']) try: diff --git a/ironic_python_agent/tests/unit/test_hardware.py b/ironic_python_agent/tests/unit/test_hardware.py index 64258757c..2822962cd 100644 --- a/ironic_python_agent/tests/unit/test_hardware.py +++ b/ironic_python_agent/tests/unit/test_hardware.py @@ -137,7 +137,8 @@ BLK_DEVICE_TEMPLATE = ( ' ROTA="0" TYPE="disk"\n' 'KNAME="sdd" MODEL="NWD-BLP4-1600 " SIZE="1765517033472" ' ' ROTA="0" TYPE="disk"\n' - 'KNAME="loop0" MODEL="" SIZE="109109248" ROTA="1" TYPE="loop"' + 'KNAME="loop0" MODEL="" SIZE="109109248" ROTA="1" TYPE="loop"\n' + 'KNAME="zram0" MODEL="" SIZE="" ROTA="0" TYPE="disk"' ) # NOTE(pas-ha) largest device is 1 byte smaller than 4GiB diff --git a/releasenotes/notes/no-zram-78cc6583f4f90a9c.yaml b/releasenotes/notes/no-zram-78cc6583f4f90a9c.yaml new file mode 100644 index 000000000..12597f6d8 --- /dev/null +++ b/releasenotes/notes/no-zram-78cc6583f4f90a9c.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + No longer tries to use zRAM devices for anything.