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 Jul 10, 2018
1 parent e484d1a commit 0a740a4
Show file tree
Hide file tree
Showing 3 changed files with 12 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.supports_streaming_refresh? }

# 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
1 change: 1 addition & 0 deletions app/models/mixins/supports_feature_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ module SupportsFeatureMixin
:snapshots => 'Snapshots',
:shutdown_guest => 'Shutdown Guest Operation',
:start => 'Start',
:streaming_refresh => 'Streaming refresh',
:suspend => 'Suspending',
:terminate => 'Terminate a VM',
:timeline => 'Query for events',
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(:supports_streaming_refresh?).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 0a740a4

Please sign in to comment.