[ARVADOS] created: 49987769d924c1bc77cbdc9e9b182c3e2cc09b2d

Git user git at public.curoverse.com
Wed Sep 28 09:31:20 EDT 2016


        at  49987769d924c1bc77cbdc9e9b182c3e2cc09b2d (commit)


commit 49987769d924c1bc77cbdc9e9b182c3e2cc09b2d
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Sep 27 17:18:06 2016 -0400

    8018: Create new container if there are retriable container requests.

diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb
index c1c3eae..037712d 100644
--- a/services/api/app/models/container.rb
+++ b/services/api/app/models/container.rb
@@ -282,6 +282,27 @@ class Container < ArvadosModel
     # that are associated with this container.
     if self.state_changed? and [Complete, Cancelled].include? self.state
       act_as_system_user do
+
+        if self.state == Cancelled
+          retryable_requests = ContainerRequest.where("priority > 0 and state = 'Committed' and container_count < container_count_max")
+        else
+          retryable_requests = []
+        end
+
+        if retryable_requests.any?
+          c = Container.create!(command: self.command,
+                                cwd: self.cwd,
+                                environment: self.environment,
+                                output_path: self.output_path,
+                                container_image: self.container_image,
+                                mounts: self.mounts,
+                                runtime_constraints: self.runtime_constraints)
+          retryable_requests.each do |cr|
+            cr.container_uuid = c.uuid
+            cr.save!
+          end
+        end
+
         # Notify container requests associated with this container
         ContainerRequest.where(container_uuid: uuid,
                                :state => ContainerRequest::Committed).each do |cr|
diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb
index f2d327e..27401fc 100644
--- a/services/api/app/models/container_request.rb
+++ b/services/api/app/models/container_request.rb
@@ -176,6 +176,9 @@ class ContainerRequest < ArvadosModel
     if state_changed? and state == Committed and container_uuid.nil?
       resolve
     end
+    if self.container_uuid != self.container_uuid_was
+      self.container_count += 1
+    end
   end
 
   def validate_runtime_constraints

commit 3fb81a4db7abbaaa67b7a18d1c4a5ce82bc232dc
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Sep 27 10:59:42 2016 -0400

    8018: Add container_count field.

diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb
index 872b3c5..f2d327e 100644
--- a/services/api/app/models/container_request.rb
+++ b/services/api/app/models/container_request.rb
@@ -23,6 +23,7 @@ class ContainerRequest < ArvadosModel
 
   api_accessible :user, extend: :common do |t|
     t.add :command
+    t.add :container_count
     t.add :container_count_max
     t.add :container_image
     t.add :container_uuid
diff --git a/services/api/db/structure.sql b/services/api/db/structure.sql
index 5f80fb2..fa4760d 100644
--- a/services/api/db/structure.sql
+++ b/services/api/db/structure.sql
@@ -289,7 +289,8 @@ CREATE TABLE container_requests (
     priority integer,
     expires_at timestamp without time zone,
     filters text,
-    updated_at timestamp without time zone NOT NULL
+    updated_at timestamp without time zone NOT NULL,
+    container_count integer DEFAULT 0
 );
 
 
@@ -2688,4 +2689,6 @@ INSERT INTO schema_migrations (version) VALUES ('20160819195725');
 
 INSERT INTO schema_migrations (version) VALUES ('20160901210110');
 
-INSERT INTO schema_migrations (version) VALUES ('20160909181442');
\ No newline at end of file
+INSERT INTO schema_migrations (version) VALUES ('20160909181442');
+
+INSERT INTO schema_migrations (version) VALUES ('20160926194129');
\ No newline at end of file

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list