Skip to content

Commit

Permalink
B #6793: Fix crash of onedb fsck on MarketPlaceApp (#3302)
Browse files Browse the repository at this point in the history
  • Loading branch information
paczerny authored Nov 22, 2024
1 parent 0357ffb commit 130713b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/onedb/fsck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ def read_config
aug.context = "/files/#{work_file_name}"
aug.load

@zone_id = aug.get('FEDERATION/ZONE_ID').to_i

@generic_quotas = []

i = 0
Expand Down
14 changes: 7 additions & 7 deletions src/onedb/fsck/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ def check_image
end

# DATA: CHECK: Check number of clones
doc.root.xpath("CLONING_OPS").each { |e|
if e.text != n_cloning_ops.to_s
log_error("Image #{oid} CLONING_OPS has #{e.text} \tis\t#{n_cloning_ops}")
e.text = n_cloning_ops
error = true
end
}
cloning_ops = doc.root.at_xpath('CLONING_OPS')

if cloning_ops.text != n_cloning_ops.to_s
log_error("Image #{oid} CLONING_OPS has #{cloning_ops.text} \tis\t#{n_cloning_ops}")
cloning_ops.content = n_cloning_ops
error = true
end

# re-do list of Images cloning this one
clones_elem = doc.root.xpath("CLONES").remove
Expand Down
25 changes: 15 additions & 10 deletions src/onedb/fsck/marketplaceapp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,21 @@ def check_marketplaceapp
market_id = doc.root.xpath('MARKETPLACE_ID').text.to_i
market_name = doc.root.xpath('MARKETPLACE').text

####################################################################
# DATA: TODO, BUG: this code will only work for a standalone oned.
# In a federation, the image ID will refer to a different image
# in each zone
####################################################################

# DATA: get image origin id. Does it work?
origin_id = doc.root.xpath('ORIGIN_ID').text.to_i
if origin_id >= 0 && doc.root.xpath('STATE').text.to_i == 2 # LOCKED
counters[:image][origin_id][:app_clones].add(row[:oid])
if doc.root.xpath('STATE').text.to_i == 2 # LOCKED
# Note: This code will only function in the zone, where the DB was created
# It may fail if the DB is transfered to a different zones
origin_id = doc.root.xpath('ORIGIN_ID').text.to_i
app_zone = doc.root.xpath('ZONE_ID').text.to_i

if origin_id >= 0 && app_zone == @zone_id && !counters[:image][origin_id].nil?
counters[:image][origin_id][:app_clones].add(row[:oid])

log_error("Marketplace App #{row[:oid]} is in locked state. "<<
"The App is probably unusable and needs to be deleted or manually fixed:\n"<<
" * Check the App data in the MarketPlace and "<<
"set state to 1 (READY) by executing `onedb update-body marketplaceapp --id #{row[:oid]}`",
false)
end
end

error = fix_permissions('MARKETPLACEAPP', row[:oid], doc)
Expand Down

0 comments on commit 130713b

Please sign in to comment.