Add step to verify disk is in an offline state
Some Windows configs will automatically set new drives as online causing diskpart setup script to fail. Signed-off-by: brianherrera <briher@amazon.com>
This commit is contained in:
@@ -252,6 +252,18 @@ def find_snapshot_id(ec2_client, snapshot_hint, repository_name, project, pipeli
|
||||
snapshot_id = snapshot['SnapshotId']
|
||||
return snapshot_id
|
||||
|
||||
|
||||
def offline_drive(disk_number=1):
|
||||
"""Use diskpart to offline a Windows drive"""
|
||||
with tempfile.NamedTemporaryFile(delete=False) as f:
|
||||
f.write(f"""
|
||||
select disk {disk_number}
|
||||
offline disk
|
||||
""".encode('utf-8'))
|
||||
subprocess.run(['diskpart', '/s', f.name])
|
||||
os.unlink(f.name)
|
||||
|
||||
|
||||
def create_volume(ec2_client, availability_zone, snapshot_hint, repository_name, project, pipeline, branch, platform, build_type, disk_size, disk_type):
|
||||
# The actual EBS default calculation for IOps is a floating point number, the closest approxmiation is 4x of the disk size for simplicity
|
||||
mount_name = get_mount_name(repository_name, project, pipeline, branch, platform, build_type)
|
||||
@@ -310,6 +322,10 @@ def create_volume(ec2_client, availability_zone, snapshot_hint, repository_name,
|
||||
def mount_volume_to_device(created):
|
||||
print('Mounting volume...')
|
||||
if os.name == 'nt':
|
||||
# Verify drive is in an offline state.
|
||||
# Some Windows configs will automatically set new drives as online causing diskpart setup script to fail.
|
||||
offline_drive()
|
||||
|
||||
f = tempfile.NamedTemporaryFile(delete=False)
|
||||
f.write("""
|
||||
select disk 1
|
||||
|
||||
Reference in New Issue
Block a user