Merge branch '16838-probe-metrics' into master
[arvados.git] / apps / workbench / app / models / proxy_work_unit.rb
index 86e8b7cfddb98a113efcdf7ac14346135039bf82..adf0bd7d671db15203b1ba26e2a6188c71cd5815 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 class ProxyWorkUnit < WorkUnit
   require 'time'
 
@@ -229,16 +233,11 @@ class ProxyWorkUnit < WorkUnit
     else
       contributors << self
     end
-    # Avoid counting reused containers
-    if started_at
-      contributors.flatten.reject{|c| c.started_at ? c.started_at < started_at : true}
-    else
-      contributors.flatten
-    end
+    contributors.flatten
   end
 
   def runningtime
-    ApplicationController.helpers.determine_wallclock_runtime(if children.any? then runtime_contributors else [self] end)
+    ApplicationController.helpers.determine_wallclock_runtime runtime_contributors
   end
 
   def show_runtime
@@ -256,16 +255,14 @@ class ProxyWorkUnit < WorkUnit
       if state_label == 'Complete'
         resp << "completed in "
       elsif state_label == 'Failed'
-         resp << "failed after "
+        resp << "failed after "
+      elsif state_label == 'Cancelled'
+        resp << "was cancelled after "
       else
         resp << "has been active for "
       end
 
-      if walltime > running_time
-        resp << ApplicationController.helpers.render_time(walltime, false)
-      else
-        resp << ApplicationController.helpers.render_time(running_time, false)
-      end
+      resp << ApplicationController.helpers.render_time(walltime, false)
 
       if finished_at
         resp << " at "
@@ -281,19 +278,17 @@ class ProxyWorkUnit < WorkUnit
     end
 
     if is_failed?
-      resp << " Check the Log tab for more detail about why it failed."
+      if runtime_status.andand[:error]
+        resp << " Check the error information below."
+      else
+        resp << " Check the Log tab for more detail about why it failed."
+      end
     end
     resp << "</p>"
 
     resp << "<p>"
     if state_label
-      resp << "It "
-      if state_label == 'Running'
-        resp << "has run"
-      else
-        resp << "ran"
-      end
-      resp << " for "
+      resp << "It has runtime of "
 
       cpu_time = cputime