X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/303424c3f3ed01f65c9f880ff1ff32bc7a46621b..8ca0b1449607ded51e908481cc4660c20f43a777:/apps/workbench/app/models/container_work_unit.rb diff --git a/apps/workbench/app/models/container_work_unit.rb b/apps/workbench/app/models/container_work_unit.rb index ed34196790..dbc81c52a3 100644 --- a/apps/workbench/app/models/container_work_unit.rb +++ b/apps/workbench/app/models/container_work_unit.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + class ContainerWorkUnit < ProxyWorkUnit attr_accessor :container attr_accessor :child_proxies @@ -54,7 +58,10 @@ class ContainerWorkUnit < ProxyWorkUnit end def can_cancel? - @proxied.is_a?(ContainerRequest) && @proxied.state == "Committed" && @proxied.priority > 0 && @proxied.editable? + @proxied.is_a?(ContainerRequest) && + @proxied.state == "Committed" && + (@proxied.priority > 0 || get(:state, @container) != 'Running') && + @proxied.editable? end def container_uuid @@ -91,14 +98,29 @@ class ContainerWorkUnit < ProxyWorkUnit end def state_label - ec = exit_code - return "Failed" if (ec && ec != 0) - - state = get_combined(:state) - - return "Queued" if state == "Locked" - return "Cancelled" if ((priority == 0) and (state == "Queued")) - state + if get(:state) == 'Final' && get(:state, @container) != 'Complete' + # Request was finalized before its container started (or the + # container was cancelled) + return 'Cancelled' + end + state = get(:state, @container) || get(:state, @proxied) + case state + when 'Locked', 'Queued' + if priority == 0 + 'On hold' + else + 'Queued' + end + when 'Complete' + if exit_code == 0 + state + else + 'Failed' + end + else + # Cancelled, Running, or Uncommitted (no container assigned) + state + end end def exit_code