Merge branch '18682-use-keyrings-instead-of-key-ids'
[arvados.git] / tools / compute-images / scripts / create-ebs-volume-nvme.patch
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: BSD-3-Clause
4
5 Make the create-ebs-volume script work with nvme devices.
6
7 diff --git a/bin/create-ebs-volume b/bin/create-ebs-volume
8 index 6857564..e3122fa 100755
9 --- a/bin/create-ebs-volume
10 +++ b/bin/create-ebs-volume
11 @@ -149,10 +149,11 @@ function get_next_logical_device() {
12      for letter in ${alphabet[@]}; do
13          # use /dev/xvdb* device names to avoid contention for /dev/sd* and /dev/xvda names
14          # only supported by HVM instances
15 -        if [ ! -b "/dev/xvdb${letter}" ]; then
16 +        if [[ $created_volumes =~ .*/dev/xvdb${letter}.* ]]; then
17 +            continue
18 +        fi
19              echo "/dev/xvdb${letter}"
20              break
21 -        fi
22      done
23  }
24  
25 @@ -323,8 +324,13 @@ function create_and_attach_volume() {
26  
27      logthis "waiting for volume $volume_id on filesystem"
28      while true; do
29 -        if [ -e "$device" ]; then
30 -            logthis "volume $volume_id on filesystem as $device"
31 +        # AWS returns e.g. vol-00338247831716a7b4, the kernel changes that to vol00338247831716a7b
32 +        valid_volume_id=`echo $volume_id |sed -e 's/[^a-zA-Z0-9]//'`
33 +        # example lsblk output:
34 +        # nvme4n1                     259:7    0  150G  0 disk            vol00338247831716a7b
35 +        if LSBLK=`lsblk -o NAME,SERIAL |grep $valid_volume_id`; then
36 +            nvme_device=/dev/`echo $LSBLK|cut -f1 -d' '`
37 +            logthis "volume $volume_id on filesystem as $nvme_device (aws device $device)"
38              break
39          fi
40          sleep 1
41 @@ -338,7 +344,7 @@ function create_and_attach_volume() {
42      > /dev/null
43      logthis "volume $volume_id DeleteOnTermination ENABLED"
44  
45 -    echo $device
46 +    echo "$nvme_device"
47  }
48  
49  create_and_attach_volume