@ #10460 | vagrant rsync should restart when rsync find chown command error

This commit is contained in:
hieptranquoc 2018-12-14 23:42:58 +07:00 committed by Chris Roberts
parent aa6908cc00
commit 480e992ea1
4 changed files with 20 additions and 2 deletions

View File

@ -668,6 +668,10 @@ module Vagrant
error_key(:push_strategy_not_provided)
end
class RsyncChownCommandError < VagrantError
error_key(:rsync_chown_command_error)
end
class RSyncError < VagrantError
error_key(:rsync_error)
end

View File

@ -217,6 +217,10 @@ module VagrantPlugins
# halt is happening. Just notify the user but don't fail out.
opts[:machine].ui.error(I18n.t(
"vagrant.rsync_communicator_not_ready_callback"))
rescue Vagrant::Errors::RsyncChownCommandError
# Error executing rsync chown command
opts[:machine].ui.error(I18n.t(
"vagrant.rsync_chown_command_error"))
rescue Vagrant::Errors::RSyncError => e
# Error executing rsync, so show an error
opts[:machine].ui.error(I18n.t(

View File

@ -23,7 +23,13 @@ module VagrantPlugins
if opts.key?(:chown) && !opts[:chown]
return
end
machine.communicate.sudo(build_rsync_chown(opts))
error_opts = {
error_class: Vagrant::Errors::RsyncChownCommandError,
error_key: :rsync_chown_command_error
}
machine.communicate.sudo(build_rsync_chown(opts), error_opts)
end
def build_rsync_chown(opts)
@ -38,7 +44,7 @@ module VagrantPlugins
"find #{guest_path} #{exclusions}" \
"'!' -type l -a " \
"'(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -exec " \
"chown #{opts[:owner]}:#{opts[:group]} '{}' + || :"
"chown #{opts[:owner]}:#{opts[:group]} '{}' +"
end
end
end

View File

@ -235,6 +235,10 @@ en:
repeats, then please fix the issue:
%{message}
rsync_chown_command_error: |-
There was an error while executing find and chown command, when file missing.
This may not be critical since rsync chown command sometimes fails, but if this message
repeats, then please fix the issue.
rsync_communicator_not_ready: |-
The machine is reporting that it is not ready for rsync to
communicate with it. Verify that this machine is properly running.