Skip to content

Commit

Permalink
Fixes #14722 - wait on subs refresh task on product create (Katello#5984
Browse files Browse the repository at this point in the history
)

as that is when the unlimited pool gets created
and if we do not wait the pool may not exist
at indexing time
(cherry picked from commit 3028d92)
  • Loading branch information
jlsherrill authored and ehelms committed May 18, 2016
1 parent d732d1c commit 56a2eff
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
15 changes: 15 additions & 0 deletions app/lib/actions/candlepin/owner/refresh_subscriptions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Actions
module Candlepin
module Owner
class RefreshSubscriptions < Candlepin::AbstractAsyncTask
input_format do
param :label
end

def invoke_external_task
::Katello::Resources::Candlepin::Subscription.refresh_for_owner(input[:label])
end
end
end
end
end
35 changes: 20 additions & 15 deletions app/lib/actions/katello/product/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,31 @@ module Katello
module Product
class Create < Actions::EntryAction
def plan(product, organization)
product.provider = organization.anonymous_provider
product.organization = organization
sequence do
product.provider = organization.anonymous_provider
product.organization = organization

cp_create = plan_action(::Actions::Candlepin::Product::Create,
:name => product.name,
:multiplier => 1,
:attributes => [{:name => "arch", :value => "ALL"}])
cp_create = plan_action(::Actions::Candlepin::Product::Create,
:name => product.name,
:multiplier => 1,
:attributes => [{:name => "arch", :value => "ALL"}])

cp_id = cp_create.output[:response][:id]
cp_id = cp_create.output[:response][:id]

sub_create = plan_action(::Actions::Candlepin::Product::CreateUnlimitedSubscription,
:owner_key => organization.label,
:product_id => cp_id)
subscription_id = sub_create.output[:response][:id]
sub_create = plan_action(::Actions::Candlepin::Product::CreateUnlimitedSubscription,
:owner_key => organization.label,
:product_id => cp_id)

product.save!
action_subject product, :cp_id => cp_id
subscription_id = sub_create.output[:response][:id]

plan_action(::Actions::Candlepin::Owner::RefreshSubscriptions,
:label => organization.label)
product.save!
action_subject product, :cp_id => cp_id

plan_self
plan_action Katello::Product::ReindexSubscriptions, product, subscription_id
plan_self
plan_action Katello::Product::ReindexSubscriptions, product, subscription_id
end
end

def finalize
Expand Down
1 change: 0 additions & 1 deletion app/lib/katello/resources/candlepin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ def get(id = nil)

def create_for_owner(owner_key, attrs)
subscription = self.post("/candlepin/owners/#{owner_key}/subscriptions", attrs.to_json, self.default_headers).body
self.put("/candlepin/owners/#{owner_key}/subscriptions", {}.to_json, self.default_headers).body
subscription
end

Expand Down

0 comments on commit 56a2eff

Please sign in to comment.