From 3099f78d1353c5a1290207c7d39c1c330ed2b196 Mon Sep 17 00:00:00 2001 From: Erez Freiberger Date: Tue, 23 Jan 2018 16:02:00 +0200 Subject: [PATCH] only use the ImageAcquireError field --- .../kubernetes/container_manager/scanning/job.rb | 2 +- .../kubernetes/container_manager/scanning/job_spec.rb | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/models/manageiq/providers/kubernetes/container_manager/scanning/job.rb b/app/models/manageiq/providers/kubernetes/container_manager/scanning/job.rb index 40a39701d7..312a1f5329 100644 --- a/app/models/manageiq/providers/kubernetes/container_manager/scanning/job.rb +++ b/app/models/manageiq/providers/kubernetes/container_manager/scanning/job.rb @@ -145,7 +145,7 @@ def analyze _log.error("analyzing image-inspector metadata for #{options[:docker_image_id]} failed with error: #{e}") end - if inspector_metadata.ImageAcquireSuccess == false + if inspector_metadata.ImageAcquireError.present? msg = "image acquiring error: #{inspector_metadata.ImageAcquireError}" _log.error(msg) return queue_signal(:abort_job, msg, 'error') diff --git a/spec/models/manageiq/providers/kubernetes/container_manager/scanning/job_spec.rb b/spec/models/manageiq/providers/kubernetes/container_manager/scanning/job_spec.rb index 6e1f4445b1..2be3916de1 100644 --- a/spec/models/manageiq/providers/kubernetes/container_manager/scanning/job_spec.rb +++ b/spec/models/manageiq/providers/kubernetes/container_manager/scanning/job_spec.rb @@ -102,11 +102,10 @@ def fetch_oscap_arf end class MockFailedImageInspectorClient < MockImageInspectorClient - def initialize(oscap_status, oscap_msg, image_acq_success = true, image_acq_error = "", *args) + def initialize(oscap_status, oscap_msg, image_acq_error = "", *args) super(*args) @oscap_status = oscap_status @oscap_msg = oscap_msg - @image_acq_success = image_acq_success @image_acq_error = image_acq_error end @@ -114,7 +113,6 @@ def fetch_metadata(*_args) os = super os["OpenSCAP"] = OpenStruct.new("Status" => @oscap_status, "ErrorMessage" => @oscap_msg) - os["ImageAcquireSuccess"] = @image_acq_success os["ImageAcquireError"] = @image_acq_error os end @@ -459,7 +457,7 @@ def create_pod_definition it 'set the ok status from image-inspector OSCAP' do allow_any_instance_of(described_class).to receive_messages( - :image_inspector_client => MockFailedImageInspectorClient.new("Success", "", true, "", IMAGE_ID) + :image_inspector_client => MockFailedImageInspectorClient.new("Success", "", "", IMAGE_ID) ) @job.signal(:start) expect(@job.state).to eq 'finished' @@ -470,7 +468,7 @@ def create_pod_definition it 'set the warn status from image-inspector OSCAP' do allow_any_instance_of(described_class).to receive_messages( - :image_inspector_client => MockFailedImageInspectorClient.new("Error", OSCAP_ERROR_MSG, true, "", IMAGE_ID) + :image_inspector_client => MockFailedImageInspectorClient.new("Error", OSCAP_ERROR_MSG, "", IMAGE_ID) ) @job.signal(:start) expect(@job.state).to eq 'finished' @@ -484,7 +482,7 @@ def create_pod_definition it 'Detects when image acquiring failed and reports the error' do IMG_ACQ_ERR = "can't find image".freeze allow_any_instance_of(described_class).to receive_messages( - :image_inspector_client => MockFailedImageInspectorClient.new("Sucess", "", false, IMG_ACQ_ERR, IMAGE_ID) + :image_inspector_client => MockFailedImageInspectorClient.new("Sucess", "", IMG_ACQ_ERR, IMAGE_ID) ) @job.signal(:start) expect(@job.state).to eq 'finished'