Skip to content

Commit

Permalink
fix for amazon linux 2023 for setting up ephemeral storage
Browse files Browse the repository at this point in the history
  • Loading branch information
pragnesh committed Sep 19, 2023
1 parent 28cec19 commit 74a6fad
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions flintrock/scripts/setup-ephemeral-storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ def device_pairs_to_tuple(pairs):
return BlockDevice(**device_dict)


def device_to_tuple(device):
device_dict = {'kname': device['name']}
return BlockDevice(**device_dict)


def get_non_root_block_devices():
"""
Get all the non-root block devices available to the host.
Expand All @@ -65,34 +70,17 @@ def get_non_root_block_devices():
"""
block_devices_raw = subprocess.check_output([
'lsblk',
'--ascii',
'--pairs',
'--bytes',
'--paths',
'--output', 'KNAME,MOUNTPOINT,SIZE',
# --inverse and --nodeps make sure that
# 1) we get the mount points for devices that have holder devices
# 2) we don't get the holder devices themselves
'--inverse',
'--nodeps',
'--noheadings',
'--fs',
'--json',
'-p',
]).decode('utf-8')
block_devices = [
device_pairs_to_tuple(line.split())
for line in block_devices_raw.splitlines()
]
non_root_block_devices = [
device for device in block_devices
if device.mountpoint != '/'
]
# Skip tiny devices, like the 1M devices that show up on
# m5 instances on EC2.
# See: https://github.com/nchammas/flintrock/issues/256
non_trivial_non_root_block_devices = [
device for device in non_root_block_devices
if int(device.size) >= 1024 ** 3
device_to_tuple(device)
for device in json.loads(block_devices_raw)['blockdevices']
if 'children' not in device and (('mountpoints' in device and device['mountpoints'][0] != '/')
or ('mountpoint' in device and device['mountpoint'] != '/'))
]
return non_trivial_non_root_block_devices
return block_devices


def unmount_devices(devices):
Expand Down

0 comments on commit 74a6fad

Please sign in to comment.