-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ext4 issues with uuidgen #3110
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,24 +137,11 @@ def map(one_vm, disk, directory) | |
|
||
return mount_dev(device, directory) unless %w[loop disk].include?(type) | ||
|
||
size = disk['SIZE'].to_i if disk['SIZE'] | ||
osize = disk['ORIGINAL_SIZE'].to_i if disk['ORIGINAL_SIZE'] | ||
|
||
cmd = "#{COMMANDS[:blkid]} -o export #{device}" | ||
_rc, o, _e = Command.execute(cmd, false) | ||
fstype = get_fstype(device) | ||
|
||
fs_type = '' | ||
return unless reset_fs_uuid(fstype, device) | ||
|
||
o.each_line {|l| | ||
next unless (m = l.match(/TYPE=(.*)/)) | ||
|
||
fs_type = m[1] | ||
break | ||
} | ||
|
||
reset_fs_uuid(fs_type, device) | ||
|
||
mount_resize_fs(device, directory, fs_type, size, osize) | ||
mount_resize_fs(device, directory, fstype, disk) | ||
end | ||
|
||
# Unmaps a disk from a given directory | ||
|
@@ -455,7 +442,7 @@ def parse_fstab(partitions, path, fstab) | |
|
||
next if %w[/ swap].include?(mount_point) | ||
|
||
partitions.each { |p| | ||
partitions.each {|p| | ||
next if p[key] != value | ||
|
||
return false unless mount_dev(p['path'], path + mount_point) | ||
|
@@ -471,7 +458,10 @@ def parse_fstab(partitions, path, fstab) | |
# @param fs_type [String] | ||
# @param size, osize [Integer] disk size and original size | ||
# @return true if success | ||
def mount_resize_fs(device, directory, fs_type, size, osize) | ||
def mount_resize_fs(device, directory, fs_type, disk) | ||
size = disk['SIZE'].to_i if disk['SIZE'] | ||
osize = disk['ORIGINAL_SIZE'].to_i if disk['ORIGINAL_SIZE'] | ||
|
||
# TODO: osize is always < size after 1st resize during deployment | ||
return mount_dev(device, directory) unless size > osize | ||
|
||
|
@@ -484,13 +474,21 @@ def mount_resize_fs(device, directory, fs_type, size, osize) | |
|
||
Command.execute("#{COMMANDS[:xfs_growfs]} -d #{directory}", false) | ||
when /ext/ | ||
_rc, o, e = Command.execute("#{COMMANDS[:e2fsck]} -f -y #{device}", false) | ||
err = "#{__method__}: failed to resize #{device}\n" | ||
|
||
_rc, o, e = check_ext4(device) | ||
|
||
if o.empty? | ||
err = "#{__method__}: failed to resize #{device}\n#{e}" | ||
OpenNebula.log_error err | ||
OpenNebula.log_error("#{err}#{e}") | ||
return | ||
else | ||
Command.execute("#{COMMANDS[:resize2fs]} #{device}", false) | ||
cmd = "#{COMMANDS[:resize2fs]} #{device}" | ||
rc, _o, e = Command.execute(cmd, false) | ||
|
||
if rc != 0 | ||
OpenNebula.log_error("#{err}#{e}") | ||
return | ||
end | ||
end | ||
|
||
rc = mount_dev(device, directory) | ||
|
@@ -512,15 +510,37 @@ def reset_fs_uuid(fs_type, device) | |
when /xfs/ | ||
cmd = "#{COMMANDS[:xfs_admin]} -U generate #{device}" | ||
when /ext/ | ||
cmd = "#{COMMANDS[:tune2fs]} tune2fs -U random #{device}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was the main issue, the command was 2 times written |
||
check_ext4(device) | ||
cmd = "#{COMMANDS[:tune2fs]} -U random #{device}" | ||
else | ||
return true | ||
end | ||
|
||
rc, _o, e = Command.execute(cmd, false) | ||
rc, o, e = Command.execute(cmd, false) | ||
return true if rc.zero? | ||
|
||
OpenNebula.log_error "#{__method__}: failed to change UUID: #{e}\n" | ||
OpenNebula.log_error "#{__method__}: error changing UUID: #{o}\n#{e}\n" | ||
nil | ||
end | ||
|
||
def get_fstype(device) | ||
cmd = "#{COMMANDS[:blkid]} -o export #{device}" | ||
_rc, o, _e = Command.execute(cmd, false) | ||
|
||
fstype = '' | ||
|
||
o.each_line {|l| | ||
next unless (m = l.match(/TYPE=(.*)/)) | ||
|
||
fstype = m[1] | ||
break | ||
} | ||
|
||
fstype | ||
end | ||
|
||
def check_ext4(part) | ||
Command.execute("#{COMMANDS[:e2fsck]} -f -y #{part}", false) | ||
end | ||
|
||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after poweroff they failed to boot again when recreating the fs uuid, it required e2fsck to be run again