From 800619e995e14c355b33c164f3886408b724460b Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Fri, 28 Jul 2017 17:37:37 +0200 Subject: [PATCH 1/3] Add ContainerImage raise event post processing job Add ContainerImage raise event post processing job, queuing the raise event as a background job, since it does not belong under the refresh. --- .../container_manager/refresher_mixin.rb | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb b/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb index f29dcfa874..319f310812 100644 --- a/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb +++ b/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb @@ -21,6 +21,28 @@ def fetch_entities(client, entities) end end end + + def manager_refresh_post_processing(_ems, _target, inventory_collections) + indexed = inventory_collections.index_by(&:name) + container_images_post_processing(indexed[:container_images]) + end + + def container_images_post_processing(container_images) + # We want this post processing job only for batches, for the rest it's after_create hook on the Model + return unless container_images.saver_strategy == :batch + + # TODO extract the batch size to Settings + batch_size = 100 + container_images.created_records.each_slice(batch_size) do |batch| + container_images_ids = batch.collect { |x| x[:id] } + MiqQueue.submit_job( + :class_name => "ContainerImage", + :method_name => 'raise_creation_event', + :args => [container_images_ids], + :priority => MiqQueue::MIN_PRIORITY + ) + end + end end end end From 1376fca21597b90b52034ada3d71250877461e1c Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Mon, 31 Jul 2017 10:14:01 +0200 Subject: [PATCH 2/3] The priority of raising event needs to be the same as of call_automate The priority of raising event needs to be the same as of call_automate. The call_automate is being called inside of this raise_creation_event, so it make sense, that he priorities are the same. --- .../providers/kubernetes/container_manager/refresher_mixin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb b/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb index 319f310812..d92e0f8966 100644 --- a/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb +++ b/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb @@ -39,7 +39,7 @@ def container_images_post_processing(container_images) :class_name => "ContainerImage", :method_name => 'raise_creation_event', :args => [container_images_ids], - :priority => MiqQueue::MIN_PRIORITY + :priority => MiqQueue::HIGH_PRIORITY ) end end From 4eadeb0af280d09a74af72c2fe9ba66c6e6bd52e Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Mon, 31 Jul 2017 10:55:01 +0200 Subject: [PATCH 3/3] Use pluralized raise_creation_events method name Use pluralized raise_creation_events method name --- .../providers/kubernetes/container_manager/refresher_mixin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb b/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb index d92e0f8966..00f3dfe2a7 100644 --- a/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb +++ b/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb @@ -37,7 +37,7 @@ def container_images_post_processing(container_images) container_images_ids = batch.collect { |x| x[:id] } MiqQueue.submit_job( :class_name => "ContainerImage", - :method_name => 'raise_creation_event', + :method_name => 'raise_creation_events', :args => [container_images_ids], :priority => MiqQueue::HIGH_PRIORITY )