Skip to content

Commit

Permalink
Fixes #37137 - Revert to old method of creating module streams after …
Browse files Browse the repository at this point in the history
…registration
  • Loading branch information
jeremylenz committed Feb 2, 2024
1 parent da4a68d commit 4b73412
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions app/models/katello/concerns/host_managed_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,21 @@ def import_enabled_repositories(repos)
end

def import_module_streams(module_streams)
# create_or_find_by avoids race conditions during concurrent registrations but clogs postgres logs with harmless errors.
# So we'll use create_or_find_by! during registration and first_or_create! otherwise.
registered_time = subscription_facet&.registered_at
use_create_or_find_by = registered_time.nil? || registered_time > 1.minute.ago
streams = {}
module_streams.each do |module_stream|
stream = AvailableModuleStream.create_or_find_by!(name: module_stream["name"],
context: module_stream["context"],
stream: module_stream["stream"])
if use_create_or_find_by
stream = AvailableModuleStream.create_or_find_by!(name: module_stream["name"],
context: module_stream["context"],
stream: module_stream["stream"])
else
stream = AvailableModuleStream.where(name: module_stream["name"],
context: module_stream["context"],
stream: module_stream["stream"]).first_or_create!
end
streams[stream.id] = module_stream
end
sync_available_module_stream_associations(streams)
Expand Down

0 comments on commit 4b73412

Please sign in to comment.