This is an automated email from the ASF dual-hosted git repository.

lfrolov pushed a commit to branch DLAB-1864
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git


The following commit(s) were added to refs/heads/DLAB-1864 by this push:
     new 5a09b5f  [DLAB-1864]: changed prepare_disk function for a case when 
kernel still uses old partition table and it has to be reread
5a09b5f is described below

commit 5a09b5fd21f15df98a085241b2edd9a91ada428e
Author: leonidfrolov <[email protected]>
AuthorDate: Fri Sep 4 13:02:04 2020 +0300

    [DLAB-1864]: changed prepare_disk function for a case when kernel still 
uses old partition table and it has to be reread
---
 .../src/general/lib/azure/actions_lib.py           | 27 ++++++++++++----------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/infrastructure-provisioning/src/general/lib/azure/actions_lib.py 
b/infrastructure-provisioning/src/general/lib/azure/actions_lib.py
index bae4574..d3891db 100644
--- a/infrastructure-provisioning/src/general/lib/azure/actions_lib.py
+++ b/infrastructure-provisioning/src/general/lib/azure/actions_lib.py
@@ -1223,31 +1223,34 @@ def prepare_disk(os_user):
         try:
             allow = False
             counter = 0
+            remount_azure_disk()
+            disk_name = sudo("lsblk | grep disk | awk '{print $1}' | sort | 
tail -n 1")
+            with settings(warn_only=True):
+                sudo('umount -l /dev/{}1'.format(disk_name))
             while not allow:
                 if counter > 4:
                     print("Unable to prepare disk")
                     sys.exit(1)
                 else:
-                    remount_azure_disk()
-                    disk_name = sudo("lsblk | grep disk | awk '{print $1}' | 
sort | tail -n 1")
-                    with settings(warn_only=True):
-                        sudo('umount -l /dev/{}1'.format(disk_name))
-                    sudo('''bash -c 'echo -e "o\nn\np\n1\n\n\nw" | fdisk 
/dev/{} 2>&1 | tee /tmp/tee.tmp' '''.format(
+                    sudo('''bash -c 'echo -e "o\nn\np\n1\n\n\nw" | fdisk 
/dev/{}' 2>&1 | tee /tmp/tee.tmp '''.format(
                         disk_name), warn_only=True)
                     out = sudo('cat /tmp/tee.tmp')
                     if 'Syncing disks' in out:
                         allow = True
-                        sudo('mkfs.ext4 -F /dev/{}1'.format(disk_name))
-                        sudo('mount /dev/{}1 /opt/'.format(disk_name))
-                        sudo(''' bash -c "echo '/dev/{}1 /opt/ ext4 
errors=remount-ro 0 1' >> /etc/fstab" '''.format(
-                            disk_name))
-                        sudo('touch /home/' + os_user + 
'/.ensure_dir/disk_ensured')
+                    elif 'The kernel still uses the old table.' in out:
+                        sudo('partprobe')
+                        allow = True
                     else:
                         counter += 1
                         time.sleep(5)
+            sudo('umount -l /dev/{}1'.format(disk_name), warn_only=True)
+            sudo('mkfs.ext4 -F /dev/{}1'.format(disk_name))
+            sudo('mount /dev/{}1 /opt/'.format(disk_name))
+            sudo(''' bash -c "echo '/dev/{}1 /opt/ ext4 errors=remount-ro 0 1' 
>> /etc/fstab" '''.format(
+                disk_name))
+            sudo('touch /home/' + os_user + '/.ensure_dir/disk_ensured')
         except Exception as err:
-            print('Error: {}'.format(str(err)))
-            traceback.print_exc()
+            print('Error:', str(err))
             sys.exit(1)
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to