Skip to content

Commit

Permalink
F #6029: Create Restic repo per VM (#2495)
Browse files Browse the repository at this point in the history
  • Loading branch information
sk4zuzu authored Feb 14, 2023
1 parent 20f6c39 commit 694ff37
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/datastore_mad/remotes/restic_downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
snaps = tokens[1].split(',').map {|s| s.split(':')[1] }
disk_path = tokens[2..].join('/')
disk_index = File.basename(disk_path).split('.')[1]
vm_id = disk_path.match('/(\d+)/backup/[^/]+$')[1].to_i

begin
# Do a sanity check if Restic is available/enabled.
Expand All @@ -81,12 +82,11 @@

rc = backup_ds.info(true)

raise StandardError, rc.message \
if OpenNebula.is_error?(backup_ds)
raise StandardError, rc.message if OpenNebula.is_error?(backup_ds)

# Pull from Restic, then post-process qcow2 disks.

rds = Restic.new backup_ds.to_xml
rds = Restic.new backup_ds.to_xml, :vm_id => vm_id

tmp_dir = "#{rds.tmp_dir}/#{SecureRandom.uuid}"
FileUtils.mkdir_p tmp_dir
Expand All @@ -101,8 +101,7 @@
mv '#{tmp_dir}/#{File.basename(disk_paths.last)}' '#{tmp_dir}/disk.#{disk_index}'
EOS

raise StandardError, rc.stderr \
if rc.code != 0
raise StandardError, rc.stderr if rc.code != 0

# Return shell code snippets according to the downloader's interface.

Expand Down
3 changes: 1 addition & 2 deletions src/lcm/LifeCycleStates.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2940,14 +2940,13 @@ void LifeCycleManager::trigger_backup_success(int vid)

oss << "<EXTRA_DATA>"
<< "<KEEP_LAST>" << keep_last << "</KEEP_LAST>"
<< "<VM_ID>" << vid << "</VM_ID>"
<< "</EXTRA_DATA>";

if ( imagem->flatten_increments(image_id, ds_id, oss.str(), error) != 0 )
{
ostringstream oss;

oss << "backup_success, cannot flatten backup increments for image "
oss << "backup_success, cannot flatten backup increments for image "
<< image_id << " : " << error;

NebulaLog::error("LCM", oss.str());
Expand Down
4 changes: 3 additions & 1 deletion src/tm_mad/lib/backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ def initialize(action_xml)

@increments[0] = @action.elements["#{prefix}/SOURCE"].text if @increments.empty?

# NOTE: In the case of backup images, there should always be just a single ID in the VMS array.
@vm_id = @action.elements["#{prefix}/VMS/ID"].text.to_i

@keep_last = @action.elements['/DS_DRIVER_ACTION_DATA/EXTRA_DATA/KEEP_LAST']&.text.to_i
@vm_id = @action.elements['/DS_DRIVER_ACTION_DATA/EXTRA_DATA/VM_ID']&.text.to_i
end

def last
Expand Down

0 comments on commit 694ff37

Please sign in to comment.