Skip to content

Commit

Permalink
Merge pull request #222 from enoodle/image_scanning_update_image_acqu…
Browse files Browse the repository at this point in the history
…iring_error_handling

only use the ImageAcquireError field
  • Loading branch information
Mooli Tayer authored Jan 28, 2018
2 parents 700ec3f + 3099f78 commit 070e98e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,17 @@ 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

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
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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'
Expand Down

0 comments on commit 070e98e

Please sign in to comment.