diff --git a/lib/floe/container_runner/docker.rb b/lib/floe/container_runner/docker.rb index 091b249a..51424da3 100644 --- a/lib/floe/container_runner/docker.rb +++ b/lib/floe/container_runner/docker.rb @@ -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) diff --git a/lib/floe/container_runner/kubernetes.rb b/lib/floe/container_runner/kubernetes.rb index cbe5112d..24af0a3c 100644 --- a/lib/floe/container_runner/kubernetes.rb +++ b/lib/floe/container_runner/kubernetes.rb @@ -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) diff --git a/lib/floe/workflow/state.rb b/lib/floe/workflow/state.rb index 02664668..0ca09680 100644 --- a/lib/floe/workflow/state.rb +++ b/lib/floe/workflow/state.rb @@ -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 @@ -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) diff --git a/lib/floe/workflow/states/task.rb b/lib/floe/workflow/states/task.rb index cc3dfd32..131eed4b 100644 --- a/lib/floe/workflow/states/task.rb +++ b/lib/floe/workflow/states/task.rb @@ -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"]) diff --git a/spec/container_runner/kubernetes_spec.rb b/spec/container_runner/kubernetes_spec.rb index eb7f0b1b..bf76a861 100644 --- a/spec/container_runner/kubernetes_spec.rb +++ b/spec/container_runner/kubernetes_spec.rb @@ -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