diff --git a/app/models/miq_product_feature.rb b/app/models/miq_product_feature.rb index c71d8da90368..f98c8c7edf60 100644 --- a/app/models/miq_product_feature.rb +++ b/app/models/miq_product_feature.rb @@ -108,6 +108,18 @@ def self.invalidate_caches @detail = nil end + # invalidate feature cache on this server and others + # + # called when data in the features change (typically tenant data). + # This then uses the queue to tell other servers they need to update as well. + def self.invalidate_caches_queue + invalidate_caches + MiqQueue.broadcast( + :class_name => name, + :method_name => "invalidate_caches" + ) + end + def self.features @feature_cache ||= begin # create hash with parent identifier and details diff --git a/app/models/tenant.rb b/app/models/tenant.rb index 0a88ce5b1728..bd772d9f0342 100644 --- a/app/models/tenant.rb +++ b/app/models/tenant.rb @@ -62,7 +62,7 @@ class Tenant < ApplicationRecord before_save :nil_blanks after_save -> { MiqProductFeature.invalidate_caches } - after_create :create_tenant_group, :create_miq_product_features_for_tenant_nodes + after_create :create_tenant_group, :create_miq_product_features_for_tenant_nodes, :update_miq_product_features_for_tenant_nodes before_destroy :ensure_can_be_destroyed def self.scope_by_tenant? @@ -307,6 +307,10 @@ def create_miq_product_features_for_tenant_nodes MiqProductFeature.seed_single_tenant_miq_product_features(self) end + def update_miq_product_features_for_tenant_nodes + MiqProductFeature.invalidate_caches_queue + end + private # when a root tenant has an attribute with a nil value, diff --git a/spec/models/host_spec.rb b/spec/models/host_spec.rb index 17a5a723244f..b9161b159bd6 100644 --- a/spec/models/host_spec.rb +++ b/spec/models/host_spec.rb @@ -135,6 +135,7 @@ it "policy passes" do expect_any_instance_of(described_class).to receive(:ipmi_power_on) + MiqQueue.delete_all @host.start status, message, result = MiqQueue.first.deliver MiqQueue.first.delivered(status, message, result)