Skip to content

Commit

Permalink
Merge pull request #296 from agrare/fix_map_parallel_checking_finishe…
Browse files Browse the repository at this point in the history
…d_states
  • Loading branch information
kbrock authored Nov 21, 2024
2 parents cce673c + 162147f commit 589d253
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/floe/container_runner/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ def docker_event_status_to_event(status)

def inspect_container(container_id)
JSON.parse(docker!("inspect", container_id).output).first
rescue
nil
rescue AwesomeSpawn::CommandResultError => err
raise Floe::ExecutionError.new("Failed to get status for container #{container_id}: #{err}")
end

def delete_container(container_id)
Expand Down
2 changes: 2 additions & 0 deletions lib/floe/container_runner/kubernetes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ def wait(timeout: nil, events: %i[create update delete])

def pod_info(pod_name)
kubeclient.get_pod(pod_name, namespace)
rescue Kubeclient::HttpError => err
raise Floe::ExecutionError.new("Failed to get status for pod #{namespace}/#{pod_name}: #{err}")
end

def pod_running?(context)
Expand Down
10 changes: 9 additions & 1 deletion lib/floe/workflow/state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,18 @@ def start(context)
mark_started(context)
end

def started?(context)
context.state_started?
end

def finish(context)
mark_finished(context)
end

def finished?(context)
context.state_finished?
end

def mark_started(context)
context.state["EnteredTime"] = Time.now.utc.iso8601

Expand Down Expand Up @@ -87,7 +95,7 @@ def mark_error(context, exception)
end

def ready?(context)
!context.state_started? || !running?(context)
!started?(context) || !running?(context)
end

def running?(context)
Expand Down
3 changes: 2 additions & 1 deletion lib/floe/workflow/states/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def finish(context)
end

def running?(context)
return true if waiting?(context)
return true if waiting?(context)
return false if finished?(context)

runner.status!(context.state["RunnerContext"])
runner.running?(context.state["RunnerContext"])
Expand Down
2 changes: 1 addition & 1 deletion spec/container_runner/kubernetes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@

it "raises an exception when getting pod info fails" do
allow(kubeclient).to receive(:get_pod).and_raise(Kubeclient::ResourceNotFoundError.new(404, "Resource Not Found", {}))
expect { subject.status!(runner_context) }.to raise_error(Kubeclient::ResourceNotFoundError, /Resource Not Found/)
expect { subject.status!(runner_context) }.to raise_error(Floe::ExecutionError, /Failed to get status for pod/)
end
end

Expand Down

0 comments on commit 589d253

Please sign in to comment.