Skip to content

Commit

Permalink
Merge pull request #99 from enoodle/scanning_job_cleanup_unqueue_signals
Browse files Browse the repository at this point in the history
Scanning::Job always cleanup all signals in cleanup
  • Loading branch information
Mooli Tayer authored Sep 27, 2017
2 parents 851fb59 + b9c49d0 commit 2a8f7ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def delete_pod
end

def cleanup(*args)
unqueue_all_signals
image = target_entity
if image
# TODO: check job success / failure
Expand Down Expand Up @@ -251,8 +252,7 @@ def cancel(*_args)
if self.state != "canceling" # ensure change of states
signal :cancel
else
unqueue_all_signals
queue_signal(:cancel_job)
signal :cancel_job
end
end
alias_method :cancel_job, :cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ def fetch_oscap_arf
end
end

context "when timeout occures during pod_wait state" do
it "should clean all signals and not fail in the state machine" do
initial_q_size = MiqQueue.all.count
MiqQueue.put(**@job.send(:queue_options), :args => [:pod_wait,])
expect(MiqQueue.all.count).to eq(initial_q_size + 1)
@job.cancel
expect(MiqQueue.all.count).to eq(initial_q_size)
end
end

context "#current_job_timeout" do
it "checks for timeout in Settings" do
stub_settings_merge(:container_scanning => {:scanning_job_timeout => '15.minutes'})
Expand Down

0 comments on commit 2a8f7ae

Please sign in to comment.