Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete dequeued shutdown_and_exit messages from MiqQueue on server start #17370

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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