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

Fix Service Retirement requests leaving the Service as 'retiring'. #530

Merged
merged 1 commit into from
May 23, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
exit MIQ_ABORT
end

unless $evm.root['service_retire_task']
$evm.log(:error, "Service retire task not found")
$evm.log(:error, "The old style retirement is incompatible with the new retirement state machine.")
exit(MIQ_ABORT)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be:

unless $evm.root['service_retire_task']
  $evm.log(:error, "Service retire task not found")
  $evm.log(:error, "The old style retirement is incompatible with the new retirement state machine.")
  exit(MIQ_ABORT)
end

This check should be placed before $evm.create_notification(:type => :service_retiring, :subject => service)


$evm.create_notification(:type => :service_retiring, :subject => service)
service.start_retirement

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def main

if @handle.root['ae_result'] == "error"
@handle.create_notification(:level => "error",
:subject => task.miq_request,
:subject => task.try(:miq_request),
:message => "Service Retire Error: #{updated_message}")
@handle.log(:error, "Service Retire Error: #{updated_message}")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
let(:miq_server) { EvmSpecHelper.local_miq_server }
let(:miq_request_task) do
FactoryBot.create(:miq_request_task,
:miq_request => request, :state => 'fred')
:miq_request => request,
:state => 'active')
end

let(:request) do
Expand Down Expand Up @@ -40,7 +41,7 @@
end

before do
allow(ae_service).to receive(:inputs) { {'status' => "fred"} }
allow(ae_service).to receive(:inputs) { {'status' => "active"} }
ae_service.root['ae_result'] = 'ok'
end

Expand All @@ -51,7 +52,7 @@

it "request message set properly" do
described_class.new(ae_service).main
msg = "Server [#{miq_server.name}] Step [] Status [fred] Message [] "
msg = "Server [#{miq_server.name}] Step [] Status [active] Message [] "
expect(svc_model_request.reload.message).to eq(msg)
end

Expand All @@ -61,4 +62,18 @@
described_class.new(ae_service).main
end
end

context "without a service retire task" do
let(:root_hash) { {} }
let(:root_object) do
obj = Spec::Support::MiqAeMockObject.new(root_hash)
obj["miq_server"] = svc_model_miq_server
obj
end

it "Task not provided" do
described_class.new(ae_service).main
expect { described_class.new(ae_service).main }.not_to raise_error
end
end
end