Skip to content

Commit

Permalink
F #6029: Normalize exit codes for rsync backup actions (#2535)
Browse files Browse the repository at this point in the history
Possible fix for "Message received: BACKUP SUCCESS 96 -" (?)
  • Loading branch information
sk4zuzu authored Mar 1, 2023
1 parent f4c42df commit e6652bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/datastore_mad/remotes/rsync/backup
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ begin
ds = TransferManager::Datastore.new(:ds_xml => ds_xml)
rescue StandardError => e
STDERR.puts e.message
exit(1)
exit(-1)
end

path = Pathname.new(base).cleanpath.to_s
Expand Down Expand Up @@ -139,4 +139,6 @@ if rc.code != 0 || rc.stdout.empty?
exit(-1)
end

puts "#{backup_id} #{rc.stdout.split[0]}"
STDOUT.puts "#{backup_id} #{rc.stdout.split[0]}"

exit(0)
14 changes: 7 additions & 7 deletions src/datastore_mad/remotes/rsync/stat
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ begin

if !diskid
STDERR.puts "Wrong format for disk filename #{parts[2]}"
exit(1)
exit(-1)
end

last_snap = parts[1].split(',')[-1].split(':')[-1]

cmd = "cat #{base_path}#{last_snap}/vm.xml"
rescue StandardError => e
STDERR.puts e.message
exit(1)
exit(-1)
end

rc = TransferManager::Action.ssh('gather_vm_xml',
Expand All @@ -102,7 +102,7 @@ rc = TransferManager::Action.ssh('gather_vm_xml',

if rc.code != 0
STDERR.puts rc.stderr
exit(1)
exit(-1)
end

vm = REXML::Document.new(Base64.decode64(rc.stdout)).root
Expand All @@ -113,16 +113,16 @@ disk = vm.elements[xpath]

if !disk
STDERR.puts "Cannot find disk #{diskid[1]} in VM backup info"
exit(1)
exit(-1)
end

size = disk.elements['//SIZE']

if !size
STDERR.puts "Cannot find size for disk #{diskid[1]} in VM backup info"
exit(1)
exit(-1)
end

puts size.text
STDOUT.puts size.text

exit 0
exit(0)

0 comments on commit e6652bd

Please sign in to comment.