Skip to content

Commit

Permalink
Merge pull request #17370 from yrudman/delete-shutdown-message-crom-q…
Browse files Browse the repository at this point in the history
…ueue-on-server-start

Delete dequeued shutdown_and_exit messages from MiqQueue on server start
  • Loading branch information
jrafanie authored May 3, 2018
2 parents a9fbab7 + cb8f107 commit 2aba99c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/miq_server/at_startup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ def clean_dequeued_messages

_log.warn("Cleaning message: #{MiqQueue.format_full_log_msg(message)}")
end
message.update_attributes(:state => MiqQueue::STATE_ERROR) rescue nil
if message.method_name == "shutdown_and_exit"
message.delete
else
message.update_attributes(:state => MiqQueue::STATE_ERROR) rescue nil
end
end
_log.info("Cleaning up dequeued messages...Complete")
end
Expand Down
8 changes: 8 additions & 0 deletions spec/models/miq_server/at_startup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
msg.reload
expect(msg.state).to eq(MiqQueue::STATE_ERROR)
end

it "deletes shutdown_and_exit messages" do
worker = FactoryGirl.create(:miq_ems_refresh_worker, :miq_server_id => @miq_server.id)
FactoryGirl.create(:miq_queue, :state => MiqQueue::STATE_DEQUEUE, :handler => worker,
:method_name => "shutdown_and_exit")
described_class.clean_dequeued_messages
expect(MiqQueue.count).to eq 0
end
end

context "where worker on other server has a message in dequeue" do
Expand Down

0 comments on commit 2aba99c

Please sign in to comment.