Skip to content

Commit

Permalink
'Improve map wait for part_table condition' (#3148)
Browse files Browse the repository at this point in the history
(cherry picked from commit 9fd7454)
  • Loading branch information
dann1 authored and rsmontero committed Mar 29, 2019
1 parent cc0b77b commit 26d75e2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/vmm_mad/remotes/lib/lxd/mapper/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -542,4 +542,10 @@ def get_fstype(device)
fstype
end

# Ensures the update of the partition table
def update_partable(dev)
cmd = "#{COMMANDS[:mount]} --fake #{dev} /mnt"
Command.execute(cmd, false)
end

end
4 changes: 1 addition & 3 deletions src/vmm_mad/remotes/lib/lxd/mapper/qcow2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def do_map(one_vm, disk, _directory)
return
end

# TODO: improve wait condition
sleep 1 # wait for parts to come out

update_partable(device)
show_parts(device) unless parts_on?(device)

device
Expand Down
14 changes: 1 addition & 13 deletions src/vmm_mad/remotes/lib/lxd/mapper/rbd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ def do_map(one_vm, disk, _directory)
return
end

# TODO: improve wait condition
sleep 1 # wait for partition table

device = out.chomp
try_mount(device)
update_partable(device)
device
end

Expand All @@ -60,13 +57,4 @@ def do_unmap(device, _one_vm, _disk, _directory)
nil
end

private

# This function tries to mount mapped devices to force update of partition
# tables
def try_mount(dev)
cmd = "#{COMMANDS[:mount]} --fake #{dev} /mnt"
Command.execute(cmd, false)
end

end

0 comments on commit 26d75e2

Please sign in to comment.