Merge branch '8484-sanity-check-collection-count' closes #8484
[arvados.git] / services / api / app / models / container.rb
index d777c0c2fe1e81148a0345fec8e71895cb403d01..787047df68e877bc8944b3c23186cc400c3ae227 100644 (file)
@@ -25,6 +25,7 @@ class Container < ArvadosModel
     t.add :container_image
     t.add :cwd
     t.add :environment
+    t.add :exit_code
     t.add :finished_at
     t.add :log
     t.add :mounts
@@ -124,7 +125,7 @@ class Container < ArvadosModel
 
     when Complete
       if self.state_changed?
-        permitted.push :state, :finished_at, :output, :log
+        permitted.push :state, :finished_at, :output, :log, :exit_code
       else
         errors.add :state, "cannot update record"
       end
@@ -152,11 +153,10 @@ class Container < ArvadosModel
     # that are associated with this container.
     if self.state_changed? and [Complete, Cancelled].include? self.state
       act_as_system_user do
-        # Try to close container requests associated with this container
+        # Notify container requests associated with this container
         ContainerRequest.where(container_uuid: uuid,
                                :state => ContainerRequest::Committed).each do |cr|
-          cr.state = ContainerRequest::Final
-          cr.save
+          cr.container_completed!
         end
 
         # Try to cancel any outstanding container requests made by this container.