Skip to content

Commit

Permalink
Don't queue EmsRefresh if using streaming refresh
Browse files Browse the repository at this point in the history
If a target's ems is using streaming refresh don't queue an EmsRefresh
because it will not be processed.
  • Loading branch information
agrare committed Jun 26, 2018
1 parent 71f88fa commit bf660b6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/ems_refresh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def self.queue_refresh(target, id = nil, opts = {})
h[e] << t unless e.nil?
end

# Drop targets on EMSs which are using streaming refresh
targets_by_ems.reject! { |ems, _| ems.streaming_refresh_enabled? }

# Queue the refreshes
task_ids = targets_by_ems.collect do |ems, ts|
ts = ts.collect { |t| [t.class.to_s, t.id] }.uniq
Expand Down
8 changes: 8 additions & 0 deletions app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,14 @@ def self.provision_workflow_class
self::ProvisionWorkflow
end

def self.streaming_refresh_enabled?
false
end

def streaming_refresh_enabled?
self.class.streaming_refresh_enabled?
end

# UI methods for determining availability of fields
def supports_port?
false
Expand Down
8 changes: 8 additions & 0 deletions spec/models/ems_refresh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
target2 = FactoryGirl.create(:vm_vmware, :ext_management_system => @ems)
queue_refresh_and_assert_queue_item(target2, [target, target2])
end

it "with streaming refresh enabled doesn't queue a refresh" do
allow(@ems).to receive(:streaming_refresh_enabled?).and_return(true)
target = @ems

described_class.queue_refresh(target)
expect(MiqQueue.count).to eq(0)
end
end

context "stopping targets unbounded growth" do
Expand Down

0 comments on commit bf660b6

Please sign in to comment.