Skip to content

Commit 72c3322

Browse files
committed
Fix unmount existing EBS
When unmount existing EBS, `blkid -c /dev/null #{device}` return PTUUID instead of UUID. UUID is required for chef resource to unmount and disable volume. Siwtch to use unmount command and remove line from fstab instead of using chef mount resource to avoid using UUID during unmount. Signed-off-by: chenwany <[email protected]>
1 parent 8607a39 commit 72c3322

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

cookbooks/aws-parallelcluster-config/resources/manage_ebs.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135

136136
vol_array.each_with_index do |volumeid, index|
137137
dev_path[index] = "/dev/disk/by-ebs-volumeid/#{volumeid}"
138-
dev_uuids[index] = get_uuid(dev_path[index])
138+
dev_uuids[index] = get_uuid_for_unmount(shared_dir_array[index])
139139

140140
# Unmount and remove volume from /etc/fstab
141141
mount shared_dir_array[index] do
@@ -170,11 +170,18 @@
170170
# unexport the volume
171171
delete_lines "remove volume from /etc/exports" do
172172
path "/etc/exports"
173-
pattern "#{shared_dir_array[index]} *"
173+
pattern "#{shared_dir_array[index]} "
174174
end
175175
end
176176

177177
execute "unexport volume" do
178178
command "exportfs -ra"
179179
end
180180
end
181+
182+
action_class do
183+
def get_uuid_for_unmount(mount_dir)
184+
cmd = Mixlib::ShellOut.new("lsblk -f | grep #{mount_dir} | awk '{{print $3}}'")
185+
cmd.run_command.stdout.strip
186+
end
187+
end

0 commit comments

Comments
 (0)